Disconnects from the XMPP server on unload as a way to facilitate API consumers.
This commit is contained in:
parent
ef7c97dc17
commit
9de34357a8
|
@ -13158,7 +13158,7 @@ module.exports = function () {
|
|||
}).call(this,"/modules/xmpp/strophe.util.js")
|
||||
},{"jitsi-meet-logger":79}],44:[function(require,module,exports){
|
||||
(function (__filename){
|
||||
/* global $, APP, config, Strophe*/
|
||||
/* global $, APP, config, Strophe */
|
||||
|
||||
var logger = require("jitsi-meet-logger").getLogger(__filename);
|
||||
var EventEmitter = require("events");
|
||||
|
@ -13176,18 +13176,14 @@ function createConnection(bosh) {
|
|||
|
||||
// Append token as URL param
|
||||
if (this.token) {
|
||||
bosh += bosh.indexOf('?') == -1 ?
|
||||
'?token=' + this.token : '&token=' + this.token;
|
||||
bosh += (bosh.indexOf('?') == -1 ? '?' : '&') + 'token=' + this.token;
|
||||
}
|
||||
|
||||
return new Strophe.Connection(bosh);
|
||||
};
|
||||
|
||||
|
||||
|
||||
//!!!!!!!!!! FIXME: ...
|
||||
function initStrophePlugins(XMPP)
|
||||
{
|
||||
function initStrophePlugins(XMPP) {
|
||||
require("./strophe.emuc")(XMPP);
|
||||
require("./strophe.jingle")(XMPP, XMPP.eventEmitter);
|
||||
// require("./strophe.moderate")(XMPP, eventEmitter);
|
||||
|
@ -13226,13 +13222,18 @@ function XMPP(options) {
|
|||
// registerListeners();
|
||||
|
||||
this.connection = createConnection(options.bosh);
|
||||
|
||||
// Setup a disconnect on unload as a way to facilitate API consumers. It
|
||||
// sounds like they would want that. A problem for them though may be if
|
||||
// they wanted to utilize the connected connection in an unload handler of
|
||||
// their own. However, it should be fairly easy for them to do that by
|
||||
// registering their unload handler before us.
|
||||
$(window).on('beforeunload unload', this.disconnect.bind(this));
|
||||
}
|
||||
|
||||
|
||||
XMPP.prototype.getConnection = function(){ return connection; };
|
||||
XMPP.prototype.getConnection = function () { return this.connection; };
|
||||
|
||||
XMPP.prototype._connect = function (jid, password) {
|
||||
|
||||
var self = this;
|
||||
// connection.connect() starts the connection process.
|
||||
//
|
||||
|
@ -13272,7 +13273,6 @@ XMPP.prototype._connect = function (jid, password) {
|
|||
self.connection.jingle.getStunAndTurnCredentials();
|
||||
}
|
||||
|
||||
|
||||
logger.info("My Jabber ID: " + self.connection.jid);
|
||||
|
||||
// Schedule ping ?
|
||||
|
@ -13293,15 +13293,14 @@ XMPP.prototype._connect = function (jid, password) {
|
|||
Strophe.getResourceFromJid(self.connection.jid)) {
|
||||
// .connected is true while connecting?
|
||||
// self.connection.send($pres());
|
||||
self.eventEmitter.emit(JitsiConnectionEvents.CONNECTION_ESTABLISHED,
|
||||
Strophe.getResourceFromJid(self.connection.jid));
|
||||
self.eventEmitter.emit(
|
||||
JitsiConnectionEvents.CONNECTION_ESTABLISHED,
|
||||
Strophe.getResourceFromJid(self.connection.jid));
|
||||
}
|
||||
} else if (status === Strophe.Status.CONNFAIL) {
|
||||
if (msg === 'x-strophe-bad-non-anon-jid') {
|
||||
anonymousConnectionFailed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
connectionFailed = true;
|
||||
}
|
||||
lastErrorMsg = msg;
|
||||
|
@ -13318,8 +13317,9 @@ XMPP.prototype._connect = function (jid, password) {
|
|||
JitsiConnectionErrors.OTHER_ERROR,
|
||||
msg ? msg : lastErrorMsg);
|
||||
} else {
|
||||
self.eventEmitter.emit(JitsiConnectionEvents.CONNECTION_DISCONNECTED,
|
||||
msg ? msg : lastErrorMsg);
|
||||
self.eventEmitter.emit(
|
||||
JitsiConnectionEvents.CONNECTION_DISCONNECTED,
|
||||
msg ? msg : lastErrorMsg);
|
||||
}
|
||||
} else if (status === Strophe.Status.AUTHFAIL) {
|
||||
// wrong password or username, prompt user
|
||||
|
@ -13331,11 +13331,12 @@ XMPP.prototype._connect = function (jid, password) {
|
|||
}
|
||||
|
||||
XMPP.prototype.connect = function (jid, password) {
|
||||
if(!jid) {
|
||||
var configDomain = this.options.hosts.anonymousdomain || this.options.hosts.domain;
|
||||
if (!jid) {
|
||||
var configDomain
|
||||
= this.options.hosts.anonymousdomain || this.options.hosts.domain;
|
||||
// Force authenticated domain if room is appended with '?login=true'
|
||||
if (this.options.hosts.anonymousdomain &&
|
||||
window.location.search.indexOf("login=true") !== -1) {
|
||||
if (this.options.hosts.anonymousdomain
|
||||
&& window.location.search.indexOf("login=true") !== -1) {
|
||||
configDomain = this.options.hosts.domain;
|
||||
}
|
||||
jid = configDomain || window.location.hostname;
|
||||
|
@ -13355,9 +13356,8 @@ XMPP.prototype.createRoom = function (roomName, options, settings) {
|
|||
} else {
|
||||
var tmpJid = Strophe.getNodeFromJid(this.connection.jid);
|
||||
|
||||
if(!authenticatedUser)
|
||||
if (!authenticatedUser)
|
||||
tmpJid = tmpJid.substr(0, 8);
|
||||
|
||||
roomjid += '/' + tmpJid;
|
||||
}
|
||||
|
||||
|
@ -13399,7 +13399,7 @@ XMPP.prototype.leaveRoom = function (jid) {
|
|||
* @returns {boolean} true iff a message was sent.
|
||||
*/
|
||||
XMPP.prototype.sendLogs = function (data) {
|
||||
if(!this.connection.emuc.focusMucJid)
|
||||
if (!this.connection.emuc.focusMucJid)
|
||||
return false;
|
||||
|
||||
var deflate = true;
|
||||
|
@ -13411,8 +13411,7 @@ XMPP.prototype.sendLogs = function (data) {
|
|||
content = Base64.encode(content);
|
||||
// XEP-0337-ish
|
||||
var message = $msg({to: this.connection.emuc.focusMucJid, type: 'normal'});
|
||||
message.c('log', { xmlns: 'urn:xmpp:eventlog',
|
||||
id: 'PeerConnectionStats'});
|
||||
message.c('log', {xmlns: 'urn:xmpp:eventlog', id: 'PeerConnectionStats'});
|
||||
message.c('message').t(content).up();
|
||||
if (deflate) {
|
||||
message.c('tag', {name: "deflated", value: "true"}).up();
|
||||
|
@ -13433,7 +13432,6 @@ XMPP.prototype.getXmppLog = function () {
|
|||
return this.connection.logger ? this.connection.logger.log : null;
|
||||
};
|
||||
|
||||
|
||||
XMPP.prototype.dial = function (to, from, roomName,roomPass) {
|
||||
this.connection.rayo.dial(to, from, roomName,roomPass);
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -62,6 +62,13 @@ function XMPP(options) {
|
|||
// registerListeners();
|
||||
|
||||
this.connection = createConnection(options.bosh);
|
||||
|
||||
// Setup a disconnect on unload as a way to facilitate API consumers. It
|
||||
// sounds like they would want that. A problem for them though may be if
|
||||
// they wanted to utilize the connected connection in an unload handler of
|
||||
// their own. However, it should be fairly easy for them to do that by
|
||||
// registering their unload handler before us.
|
||||
$(window).on('beforeunload unload', this.disconnect.bind(this));
|
||||
}
|
||||
|
||||
XMPP.prototype.getConnection = function () { return this.connection; };
|
||||
|
|
Loading…
Reference in New Issue