Permalink
Browse files

feat(XMPPEvents): add CONNECTION_ESTABLISHED

  • Loading branch information...
paweldomas committed Feb 15, 2017
1 parent be17176 commit 742950582ec1c5562eb10d91265f078fea47fab2
Showing with 20 additions and 4 deletions.
  1. +16 −4 modules/xmpp/JingleSessionPC.js
  2. +4 −0 service/xmpp/XMPPEvents.js
@@ -61,6 +61,13 @@ export default class JingleSessionPC extends JingleSession {
this.failICE = !!options.failICE;
this.modificationQueue = async.queue(this._processQueueTasks.bind(this), 1);
/**
* Flag used to guarantee that the connection established event is
* triggered just once.
* @type {boolean}
*/
this.wasConnected = false;
}
doInitialize() {
@@ -143,10 +150,15 @@ export default class JingleSessionPC extends JingleSession {
case 'connected':
// Informs interested parties that the connection has been
// restored.
if (self.peerconnection.signalingState === 'stable'
&& self.isreconnect) {
self.room.eventEmitter.emit(
XMPPEvents.CONNECTION_RESTORED);
if (self.peerconnection.signalingState === 'stable') {
if (self.isreconnect) {
self.room.eventEmitter.emit(
XMPPEvents.CONNECTION_RESTORED, self);
} else if (!self.wasConnected) {
self.room.eventEmitter.emit(
XMPPEvents.CONNECTION_ESTABLISHED, self);
}
self.wasConnected = true;
}
self.isreconnect = false;
@@ -18,6 +18,10 @@ var XMPPEvents = {
CALL_ENDED: "xmpp.callended.jingle",
CHAT_ERROR_RECEIVED: "xmpp.chat_error_received",
CONFERENCE_SETUP_FAILED: "xmpp.conference_setup_failed",
/**
* This event is when the ICE connects for the first time.
*/
CONNECTION_ESTABLISHED: "xmpp.connection.connected",
// Designates an event indicating that the connection to the XMPP server
// failed.
CONNECTION_FAILED: "xmpp.connection.failed",

0 comments on commit 7429505

Please sign in to comment.