Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(visitors): Adds an option to skip redirections. #2575

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/xmpp/ChatRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export default class ChatRoom extends Listenable {
const preJoin
= this.options.disableFocus
? Promise.resolve()
: this.xmpp.moderator.sendConferenceRequest(this.roomjid);
: this.xmpp.moderator.sendConferenceRequest(this.roomjid, this.options.skipRedirect);

preJoin.then(() => {
this.sendPresence(true);
Expand Down
16 changes: 9 additions & 7 deletions modules/xmpp/moderator.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export default class Moderator extends Listenable {
* @returns {Promise} - Resolved when Jicofo allows to join the room. It's never
* rejected, and it'll keep on pinging Jicofo forever.
*/
sendConferenceRequest(roomJid) {
sendConferenceRequest(roomJid, skipRedirect) {
// there is no point of sending conference iq when in visitor mode (disableFocus)
// when we have sent early the conference request via http
// we want to skip sending it here, or visitors can loop
Expand All @@ -310,7 +310,7 @@ export default class Moderator extends Listenable {

this.connection.sendIQ(
this._createConferenceIq(roomJid),
result => this._handleIqSuccess(roomJid, result, resolve),
result => this._handleIqSuccess(roomJid, result, resolve, skipRedirect),
error => this._handleIqError(roomJid, error, resolve));

// XXX We're pressed for time here because we're beginning a complex
Expand Down Expand Up @@ -347,7 +347,7 @@ export default class Moderator extends Listenable {
}
response.json()
.then(resultJson => {
this._handleSuccess(roomJid, resultJson, resolve);
this._handleSuccess(roomJid, resultJson, resolve, skipRedirect);
});
})
.catch(error => {
Expand All @@ -365,9 +365,10 @@ export default class Moderator extends Listenable {
* @param roomJid
* @param conferenceRequest
* @param callback
* @param skipRedirect
* @private
*/
_handleSuccess(roomJid, conferenceRequest, callback) {
_handleSuccess(roomJid, conferenceRequest, callback, skipRedirect) {
// Reset the error timeout (because we haven't failed here).
this.getNextErrorTimeout(true);

Expand Down Expand Up @@ -408,7 +409,7 @@ export default class Moderator extends Listenable {
this.getNextTimeout(true);

// we want to ignore redirects when this is jibri (record/live-stream or a sip jibri)
if (conferenceRequest.vnode && !this.options.iAmRecorder && !this.options.iAmSipGateway) {
if (!skipRedirect && conferenceRequest.vnode && !this.options.iAmRecorder && !this.options.iAmSipGateway) {
logger.warn(`Redirected to: ${conferenceRequest.vnode} with focusJid ${conferenceRequest.focusJid}`);

this.xmpp.eventEmitter.emit(CONNECTION_REDIRECTED, conferenceRequest.vnode, conferenceRequest.focusJid);
Expand Down Expand Up @@ -518,12 +519,13 @@ export default class Moderator extends Listenable {
* @param result - the success (i.e. non-error) result of the request that {@link #sendConferenecRequest} sent
* @param {Function} callback - the function to be called back upon the
* successful allocation of the conference focus
* @param skipRedirect - Whether to skip the redirect.
*/
_handleIqSuccess(roomJid, result, callback) {
_handleIqSuccess(roomJid, result, callback, skipRedirect) {
// Setup config options
const conferenceRequest = this._parseConferenceIq(result);

this._handleSuccess(roomJid, conferenceRequest, callback);
this._handleSuccess(roomJid, conferenceRequest, callback, skipRedirect);
}

/**
Expand Down