Fixes ping merge issues.

This commit is contained in:
paweldomas 2015-11-20 14:17:32 -06:00
parent 6243c8fb96
commit a85024e066
2 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,7 @@
/* global $, $iq, Strophe */
var logger = require("jitsi-meet-logger").getLogger(__filename);
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
/**
@ -67,7 +69,7 @@ module.exports = function (XMPP, eventEmitter) {
callback(ping.length > 0);
},
function (error) {
console.error("Ping feature discovery error", error);
logger.error("Ping feature discovery error", error);
callback(false);
}
);
@ -82,7 +84,7 @@ module.exports = function (XMPP, eventEmitter) {
*/
startInterval: function (remoteJid, interval) {
if (this.intervalId) {
console.error("Ping task scheduled already");
logger.error("Ping task scheduled already");
return;
}
if (!interval)
@ -96,14 +98,14 @@ module.exports = function (XMPP, eventEmitter) {
},
function (error) {
self.failedPings += 1;
console.error(
logger.error(
"Ping " + (error ? "error" : "timeout"), error);
if (self.failedPings >= PING_THRESHOLD) {
self.connection.disconnect();
}
}, PING_TIMEOUT);
}, interval);
console.info("XMPP pings will be sent every " + interval + " ms");
logger.info("XMPP pings will be sent every " + interval + " ms");
},
/**
@ -114,7 +116,7 @@ module.exports = function (XMPP, eventEmitter) {
window.clearInterval(this.intervalId);
this.intervalId = null;
this.failedPings = 0;
console.info("Ping interval cleared");
logger.info("Ping interval cleared");
}
}
});

View File

@ -114,14 +114,14 @@ XMPP.prototype._connect = function (jid, password) {
logger.info("My Jabber ID: " + self.connection.jid);
// Schedule ping ?
var pingJid = connection.domain;
connection.ping.hasPingSupport(
var pingJid = self.connection.domain;
self.connection.ping.hasPingSupport(
pingJid,
function (hasPing) {
if (hasPing)
connection.ping.startInterval(pingJid);
self.connection.ping.startInterval(pingJid);
else
console.warn("Ping NOT supported by " + pingJid);
logger.warn("Ping NOT supported by " + pingJid);
}
);