Browse Source

Fixes issues after review PR #166

master
hristoterezov 8 years ago
parent
commit
b1e4c8debe

+ 36
- 42
JitsiConference.js View File

37
     this.eventEmitter = new EventEmitter();
37
     this.eventEmitter = new EventEmitter();
38
     this.settings = new Settings();
38
     this.settings = new Settings();
39
     this.retries = 0;
39
     this.retries = 0;
40
+    this.options = options;
41
+    this.eventManager = new JitsiConferenceEventManager(this);
40
     this._init(options);
42
     this._init(options);
41
     this.componentsVersions = new ComponentsVersions(this);
43
     this.componentsVersions = new ComponentsVersions(this);
42
-    this.rtc = new RTC(this, options);
43
-    this.statistics = new Statistics(this.xmpp, {
44
-        callStatsID: this.options.config.callStatsID,
45
-        callStatsSecret: this.options.config.callStatsSecret,
46
-        disableThirdPartyRequests:
47
-            this.options.config.disableThirdPartyRequests,
48
-        roomName: this.options.name
49
-    });
50
-    this.eventManager = new JitsiConferenceEventManager(this);
51
-    this._setupListeners();
52
     this.participants = {};
44
     this.participants = {};
53
     this.lastDominantSpeaker = null;
45
     this.lastDominantSpeaker = null;
54
     this.dtmfManager = null;
46
     this.dtmfManager = null;
68
 
60
 
69
 /**
61
 /**
70
  * Initializes the conference object properties
62
  * Initializes the conference object properties
71
- * @param options overrides this.options
63
+ * @param options {object}
64
+ * @param connection {JitsiConnection} overrides this.connection
65
+ * @param roomState {object} the state of the ChatRoom instance received by
66
+ * ChatRoom.exportState. If this property is set it will be passed to
67
+ * ChatRoom.loadState
72
  */
68
  */
73
 JitsiConference.prototype._init = function (options) {
69
 JitsiConference.prototype._init = function (options) {
74
     if(!options)
70
     if(!options)
75
         options = {};
71
         options = {};
76
-    if(!this.options) {
77
-        this.options = options;
78
-    } else {
79
-        // Override config options
80
-        var config = options.config || {};
81
-        for(var key in config)
82
-            this.options.config[key] = config[key] || this.options.config[key];
83
-    }
84
 
72
 
85
     // Override connection and xmpp properties (Usefull if the connection
73
     // Override connection and xmpp properties (Usefull if the connection
86
     // reloaded)
74
     // reloaded)
87
-    this.connection = options.connection || this.connection;
88
-    this.xmpp = this.connection.xmpp;
75
+    if(options.connection) {
76
+        this.connection = options.connection;
77
+        this.xmpp = this.connection.xmpp;
78
+        // Setup XMPP events only if we have new connection object.
79
+        this.eventManager.setupXMPPListeners();
80
+    }
81
+
89
     this.retries++;
82
     this.retries++;
90
     this.room = this.xmpp.createRoom(this.options.name, this.options.config,
83
     this.room = this.xmpp.createRoom(this.options.name, this.options.config,
91
         this.settings, (this.retries < 4 ? 3 : null));
84
         this.settings, (this.retries < 4 ? 3 : null));
92
 
85
 
86
+    this.eventManager.setupChatRoomListeners();
87
+
93
     //restore previous presence options
88
     //restore previous presence options
94
     if(options.roomState) {
89
     if(options.roomState) {
95
         this.room.loadState(options.roomState);
90
         this.room.loadState(options.roomState);
96
     }
91
     }
97
     this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
92
     this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
93
+
94
+    if(!this.rtc) {
95
+        this.rtc = new RTC(this, options);
96
+        this.eventManager.setupRTCListeners();
97
+    }
98
+
99
+
100
+    if(!this.statistics) {
101
+        this.statistics = new Statistics(this.xmpp, {
102
+            callStatsID: this.options.config.callStatsID,
103
+            callStatsSecret: this.options.config.callStatsSecret,
104
+            disableThirdPartyRequests:
105
+                this.options.config.disableThirdPartyRequests,
106
+            roomName: this.options.name
107
+        });
108
+    }
109
+    // Always add listeners because on reload we are executing leave and the
110
+    // listeners are removed from statistics module.
111
+    this.eventManager.setupStatisticsListeners();
98
 }
112
 }
99
 
113
 
100
 /**
114
 /**
107
         options = {};
121
         options = {};
108
     options.roomState = roomState;
122
     options.roomState = roomState;
109
     this.leave(true);
123
     this.leave(true);
110
-    this._reinitialize(options);
111
-}
112
-
113
-/**
114
- * Reinitializes JitsiConference instance
115
- * @param options {object} options to be overriden
116
- */
117
-JitsiConference.prototype._reinitialize = function (options) {
118
-    this._init(options || {});
119
-    this.eventManager.setupChatRoomListeners();
120
-    this.eventManager.setupStatisticsListeners();
124
+    this._init(options);
121
     this.join();
125
     this.join();
122
 }
126
 }
123
 
127
 
1164
     Statistics.sendLog(message);
1168
     Statistics.sendLog(message);
1165
 };
1169
 };
1166
 
1170
 
1167
-/**
1168
- * Setups the listeners needed for the conference.
1169
- */
1170
-JitsiConference.prototype._setupListeners = function () {
1171
-    this.eventManager.setupXMPPListeners();
1172
-    this.eventManager.setupChatRoomListeners();
1173
-    this.eventManager.setupRTCListeners();
1174
-    this.eventManager.setupStatisticsListeners();
1175
-};
1176
-
1177
 /**
1171
 /**
1178
  * Checks if the user identified by given <tt>mucJid</tt> is the conference
1172
  * Checks if the user identified by given <tt>mucJid</tt> is the conference
1179
  * focus.
1173
  * focus.

+ 54
- 48
JitsiConferenceEventManager.js View File

16
  */
16
  */
17
 function JitsiConferenceEventManager(conference) {
17
 function JitsiConferenceEventManager(conference) {
18
     this.conference = conference;
18
     this.conference = conference;
19
-    this.chatRoomForwarder = new EventEmitterForwarder(this.conference.room,
20
-        this.conference.eventEmitter);
19
+
20
+    //Listeners related to the conference only
21
+    conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
22
+        function (track) {
23
+            if(!track.isLocal() || !conference.statistics)
24
+                return;
25
+            conference.statistics.sendMuteEvent(track.isMuted(),
26
+                track.getType());
27
+        });
21
 }
28
 }
22
 
29
 
23
 /**
30
 /**
25
  */
32
  */
26
 JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
33
 JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
27
     var conference = this.conference;
34
     var conference = this.conference;
35
+    var chatRoom = conference.room;
36
+    this.chatRoomForwarder = new EventEmitterForwarder(chatRoom,
37
+        this.conference.eventEmitter);
28
 
38
 
29
-    conference.room.addListener(XMPPEvents.ICE_RESTARTING, function () {
39
+    chatRoom.addListener(XMPPEvents.ICE_RESTARTING, function () {
30
         // All data channels have to be closed, before ICE restart
40
         // All data channels have to be closed, before ICE restart
31
         // otherwise Chrome will not trigger "opened" event for the channel
41
         // otherwise Chrome will not trigger "opened" event for the channel
32
         // established with the new bridge
42
         // established with the new bridge
33
         conference.rtc.closeAllDataChannels();
43
         conference.rtc.closeAllDataChannels();
34
     });
44
     });
35
 
45
 
36
-    conference.room.addListener(XMPPEvents.REMOTE_TRACK_ADDED,
46
+    chatRoom.addListener(XMPPEvents.REMOTE_TRACK_ADDED,
37
         function (data) {
47
         function (data) {
38
             var track = conference.rtc.createRemoteTrack(data);
48
             var track = conference.rtc.createRemoteTrack(data);
39
             if (track) {
49
             if (track) {
41
             }
51
             }
42
         }
52
         }
43
     );
53
     );
44
-    conference.room.addListener(XMPPEvents.REMOTE_TRACK_REMOVED,
54
+    chatRoom.addListener(XMPPEvents.REMOTE_TRACK_REMOVED,
45
         function (streamId, trackId) {
55
         function (streamId, trackId) {
46
             conference.getParticipants().forEach(function(participant) {
56
             conference.getParticipants().forEach(function(participant) {
47
                 var tracks = participant.getTracks();
57
                 var tracks = participant.getTracks();
59
         }
69
         }
60
     );
70
     );
61
 
71
 
62
-    conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
72
+    chatRoom.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
63
         function (value) {
73
         function (value) {
64
             // set isMutedByFocus when setAudioMute Promise ends
74
             // set isMutedByFocus when setAudioMute Promise ends
65
             conference.rtc.setAudioMute(value).then(
75
             conference.rtc.setAudioMute(value).then(
111
         JitsiConferenceEvents.CONFERENCE_FAILED,
121
         JitsiConferenceEvents.CONFERENCE_FAILED,
112
         JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
122
         JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
113
 
123
 
114
-    conference.room.addListener(XMPPEvents.JINGLE_FATAL_ERROR,
124
+    chatRoom.addListener(XMPPEvents.JINGLE_FATAL_ERROR,
115
         function (session, error) {
125
         function (session, error) {
116
             conference.eventEmitter.emit(
126
             conference.eventEmitter.emit(
117
                 JitsiConferenceEvents.CONFERENCE_FAILED,
127
                 JitsiConferenceEvents.CONFERENCE_FAILED,
118
                 JitsiConferenceErrors.JINGLE_FATAL_ERROR, error);
128
                 JitsiConferenceErrors.JINGLE_FATAL_ERROR, error);
119
         });
129
         });
120
 
130
 
131
+    chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
132
+        function (pc) {
133
+            chatRoom.eventEmitter.emit(
134
+                XMPPEvents.CONFERENCE_SETUP_FAILED,
135
+                new Error("ICE fail"));
136
+        });
137
+
121
     this.chatRoomForwarder.forward(XMPPEvents.MUC_DESTROYED,
138
     this.chatRoomForwarder.forward(XMPPEvents.MUC_DESTROYED,
122
         JitsiConferenceEvents.CONFERENCE_FAILED,
139
         JitsiConferenceEvents.CONFERENCE_FAILED,
123
         JitsiConferenceErrors.CONFERENCE_DESTROYED);
140
         JitsiConferenceErrors.CONFERENCE_DESTROYED);
130
         JitsiConferenceEvents.CONFERENCE_FAILED,
147
         JitsiConferenceEvents.CONFERENCE_FAILED,
131
         JitsiConferenceErrors.FOCUS_DISCONNECTED);
148
         JitsiConferenceErrors.FOCUS_DISCONNECTED);
132
 
149
 
133
-    conference.room.addListener(XMPPEvents.FOCUS_LEFT,
150
+    chatRoom.addListener(XMPPEvents.FOCUS_LEFT,
134
         function () {
151
         function () {
135
             if(!conference.connection._reload())
152
             if(!conference.connection._reload())
136
                 conference.eventEmitter.emit(
153
                 conference.eventEmitter.emit(
138
                     JitsiConferenceErrors.FOCUS_LEFT);
155
                     JitsiConferenceErrors.FOCUS_LEFT);
139
         });
156
         });
140
 
157
 
141
-    conference.room.addListener(XMPPEvents.ALLOCATE_FOCUS_MAX_RETRIES_ERROR,
158
+    chatRoom.addListener(XMPPEvents.ALLOCATE_FOCUS_MAX_RETRIES_ERROR,
142
         function () {
159
         function () {
143
             conference.connection._reload();
160
             conference.connection._reload();
144
         });
161
         });
159
         JitsiConferenceEvents.CONFERENCE_FAILED,
176
         JitsiConferenceEvents.CONFERENCE_FAILED,
160
         JitsiConferenceErrors.SETUP_FAILED);
177
         JitsiConferenceErrors.SETUP_FAILED);
161
 
178
 
162
-    conference.room.setParticipantPropertyListener(function (node, from) {
179
+    chatRoom.setParticipantPropertyListener(function (node, from) {
163
         var participant = conference.getParticipantById(from);
180
         var participant = conference.getParticipantById(from);
164
         if (!participant) {
181
         if (!participant) {
165
             return;
182
             return;
173
     this.chatRoomForwarder.forward(XMPPEvents.KICKED,
190
     this.chatRoomForwarder.forward(XMPPEvents.KICKED,
174
         JitsiConferenceEvents.KICKED);
191
         JitsiConferenceEvents.KICKED);
175
 
192
 
176
-    conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED,
193
+    chatRoom.addListener(XMPPEvents.MUC_MEMBER_JOINED,
177
         conference.onMemberJoined.bind(conference));
194
         conference.onMemberJoined.bind(conference));
178
-    conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT,
195
+    chatRoom.addListener(XMPPEvents.MUC_MEMBER_LEFT,
179
         conference.onMemberLeft.bind(conference));
196
         conference.onMemberLeft.bind(conference));
180
 
197
 
181
-    conference.room.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
198
+    chatRoom.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
182
         conference.onDisplayNameChanged.bind(conference));
199
         conference.onDisplayNameChanged.bind(conference));
183
 
200
 
184
-    conference.room.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, function (role) {
201
+    chatRoom.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, function (role) {
185
         conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED,
202
         conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED,
186
             conference.myUserId(), role);
203
             conference.myUserId(), role);
187
 
204
 
195
         }
212
         }
196
     });
213
     });
197
 
214
 
198
-    conference.room.addListener(XMPPEvents.MUC_ROLE_CHANGED,
215
+    chatRoom.addListener(XMPPEvents.MUC_ROLE_CHANGED,
199
         conference.onUserRoleChanged.bind(conference));
216
         conference.onUserRoleChanged.bind(conference));
200
 
217
 
201
-    conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED,
218
+    chatRoom.addListener(AuthenticationEvents.IDENTITY_UPDATED,
202
         function (authEnabled, authIdentity) {
219
         function (authEnabled, authIdentity) {
203
             conference.authEnabled = authEnabled;
220
             conference.authEnabled = authEnabled;
204
             conference.authIdentity = authIdentity;
221
             conference.authIdentity = authIdentity;
207
                 authIdentity);
224
                 authIdentity);
208
         });
225
         });
209
 
226
 
210
-    conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED,
227
+    chatRoom.addListener(XMPPEvents.MESSAGE_RECEIVED,
211
         function (jid, displayName, txt, myJid, ts) {
228
         function (jid, displayName, txt, myJid, ts) {
212
             var id = Strophe.getResourceFromJid(jid);
229
             var id = Strophe.getResourceFromJid(jid);
213
             conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED,
230
             conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED,
214
                 id, txt, ts);
231
                 id, txt, ts);
215
         });
232
         });
216
 
233
 
217
-    conference.room.addListener(XMPPEvents.PRESENCE_STATUS,
234
+    chatRoom.addListener(XMPPEvents.PRESENCE_STATUS,
218
         function (jid, status) {
235
         function (jid, status) {
219
             var id = Strophe.getResourceFromJid(jid);
236
             var id = Strophe.getResourceFromJid(jid);
220
             var participant = conference.getParticipantById(id);
237
             var participant = conference.getParticipantById(id);
226
                 JitsiConferenceEvents.USER_STATUS_CHANGED, id, status);
243
                 JitsiConferenceEvents.USER_STATUS_CHANGED, id, status);
227
         });
244
         });
228
 
245
 
229
-    conference.room.addPresenceListener("startmuted", function (data, from) {
246
+    chatRoom.addPresenceListener("startmuted", function (data, from) {
230
         var isModerator = false;
247
         var isModerator = false;
231
         if (conference.myUserId() === from && conference.isModerator()) {
248
         if (conference.myUserId() === from && conference.isModerator()) {
232
             isModerator = true;
249
             isModerator = true;
264
         }
281
         }
265
     });
282
     });
266
 
283
 
267
-    conference.room.addPresenceListener("videomuted", function (values, from) {
284
+    chatRoom.addPresenceListener("videomuted", function (values, from) {
268
         conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
285
         conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
269
             values.value == "true", from);
286
             values.value == "true", from);
270
     });
287
     });
271
 
288
 
272
-    conference.room.addPresenceListener("audiomuted", function (values, from) {
289
+    chatRoom.addPresenceListener("audiomuted", function (values, from) {
273
         conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
290
         conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
274
             values.value == "true", from);
291
             values.value == "true", from);
275
     });
292
     });
276
 
293
 
277
-    conference.room.addPresenceListener("videoType", function(data, from) {
294
+    chatRoom.addPresenceListener("videoType", function(data, from) {
278
         conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
295
         conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
279
     });
296
     });
280
 
297
 
281
-    conference.room.addPresenceListener("devices", function (data, from) {
298
+    chatRoom.addPresenceListener("devices", function (data, from) {
282
         var isAudioAvailable = false;
299
         var isAudioAvailable = false;
283
         var isVideoAvailable = false;
300
         var isVideoAvailable = false;
284
         data.children.forEach(function (config) {
301
         data.children.forEach(function (config) {
322
     });
339
     });
323
 
340
 
324
     if(conference.statistics) {
341
     if(conference.statistics) {
325
-        conference.room.addListener(XMPPEvents.DISPOSE_CONFERENCE,
342
+        chatRoom.addListener(XMPPEvents.DISPOSE_CONFERENCE,
326
             function () {
343
             function () {
327
                 conference.statistics.dispose();
344
                 conference.statistics.dispose();
328
             });
345
             });
329
 
346
 
330
-        conference.room.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
347
+        chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
331
             function (pc) {
348
             function (pc) {
332
                 conference.statistics.sendIceConnectionFailedEvent(pc);
349
                 conference.statistics.sendIceConnectionFailedEvent(pc);
333
-                conference.room.eventEmitter.emit(
334
-                    XMPPEvents.CONFERENCE_SETUP_FAILED,
335
-                    new Error("ICE fail"));
336
             });
350
             });
337
 
351
 
338
-        conference.room.addListener(XMPPEvents.CREATE_OFFER_FAILED,
352
+        chatRoom.addListener(XMPPEvents.CREATE_OFFER_FAILED,
339
             function (e, pc) {
353
             function (e, pc) {
340
                 conference.statistics.sendCreateOfferFailed(e, pc);
354
                 conference.statistics.sendCreateOfferFailed(e, pc);
341
             });
355
             });
342
 
356
 
343
-        conference.room.addListener(XMPPEvents.CREATE_ANSWER_FAILED,
357
+        chatRoom.addListener(XMPPEvents.CREATE_ANSWER_FAILED,
344
             function (e, pc) {
358
             function (e, pc) {
345
                 conference.statistics.sendCreateAnswerFailed(e, pc);
359
                 conference.statistics.sendCreateAnswerFailed(e, pc);
346
             });
360
             });
347
 
361
 
348
-        conference.room.addListener(XMPPEvents.SET_LOCAL_DESCRIPTION_FAILED,
362
+        chatRoom.addListener(XMPPEvents.SET_LOCAL_DESCRIPTION_FAILED,
349
             function (e, pc) {
363
             function (e, pc) {
350
                 conference.statistics.sendSetLocalDescFailed(e, pc);
364
                 conference.statistics.sendSetLocalDescFailed(e, pc);
351
             });
365
             });
352
 
366
 
353
-        conference.room.addListener(XMPPEvents.SET_REMOTE_DESCRIPTION_FAILED,
367
+        chatRoom.addListener(XMPPEvents.SET_REMOTE_DESCRIPTION_FAILED,
354
             function (e, pc) {
368
             function (e, pc) {
355
                 conference.statistics.sendSetRemoteDescFailed(e, pc);
369
                 conference.statistics.sendSetRemoteDescFailed(e, pc);
356
             });
370
             });
357
 
371
 
358
-        conference.room.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
372
+        chatRoom.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
359
             function (e, pc) {
373
             function (e, pc) {
360
                 conference.statistics.sendAddIceCandidateFailed(e, pc);
374
                 conference.statistics.sendAddIceCandidateFailed(e, pc);
361
             });
375
             });
421
             // mute existing local tracks because this is initial mute from
435
             // mute existing local tracks because this is initial mute from
422
             // Jicofo
436
             // Jicofo
423
             conference.getLocalTracks().forEach(function (track) {
437
             conference.getLocalTracks().forEach(function (track) {
424
-                if (conference.startAudioMuted && track.isAudioTrack()) {
425
-                    track.mute();
426
-                }
427
-                if (conference.startVideoMuted && track.isVideoTrack()) {
428
-                    track.mute();
438
+                switch (track.getType()) {
439
+                    case MediaType.AUDIO:
440
+                        conference.startAudioMuted && track.mute();
441
+                        break;
442
+                    case MediaType.VIDEO:
443
+                        conference.startVideoMuted && track.mute();
444
+                        break;
429
                 }
445
                 }
430
             });
446
             });
431
 
447
 
442
         return;
458
         return;
443
 
459
 
444
     conference.statistics.addAudioLevelListener(function (ssrc, level) {
460
     conference.statistics.addAudioLevelListener(function (ssrc, level) {
445
-        var userId = null;
446
-
447
         var resource = conference.rtc.getResourceBySSRC(ssrc);
461
         var resource = conference.rtc.getResourceBySSRC(ssrc);
448
         if (!resource)
462
         if (!resource)
449
             return;
463
             return;
482
         conference.eventEmitter.emit(
496
         conference.eventEmitter.emit(
483
             JitsiConferenceEvents.CONNECTION_STATS, stats);
497
             JitsiConferenceEvents.CONNECTION_STATS, stats);
484
     });
498
     });
485
-
486
-    conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
487
-        function (track) {
488
-            if(!track.isLocal())
489
-                return;
490
-            var type = (track.getType() === "audio")? "audio" : "video";
491
-            conference.statistics.sendMuteEvent(track.isMuted(), type);
492
-        });
493
 };
499
 };
494
 
500
 
495
 module.exports = JitsiConferenceEventManager;
501
 module.exports = JitsiConferenceEventManager;

+ 4
- 5
JitsiConnection.js View File

58
 
58
 
59
 /**
59
 /**
60
  * Reloads the JitsiConnection instance and all related conferences
60
  * Reloads the JitsiConnection instance and all related conferences
61
- * @param options {object} options to be overriden
62
  */
61
  */
63
-JitsiConnection.prototype._reload = function (options) {
62
+JitsiConnection.prototype._reload = function () {
64
     if(this.retryOnFail === 0)
63
     if(this.retryOnFail === 0)
65
         return false;
64
         return false;
66
     this.retryOnFail--;
65
     this.retryOnFail--;
73
         this._reloadConferences.bind(this, states);
72
         this._reloadConferences.bind(this, states);
74
     this.addEventListener(JitsiConnectionEvents.CONNECTION_ESTABLISHED,
73
     this.addEventListener(JitsiConnectionEvents.CONNECTION_ESTABLISHED,
75
         this.connectionEstablishedHandler);
74
         this.connectionEstablishedHandler);
76
-    this.xmpp.reload(options || {});
75
+    this.xmpp.reload();
77
     return true;
76
     return true;
78
 }
77
 }
79
 
78
 
87
     this.connectionEstablishedHandler = null;
86
     this.connectionEstablishedHandler = null;
88
     states = states || {};
87
     states = states || {};
89
     for(var name in this.conferences) {
88
     for(var name in this.conferences) {
90
-        this.conferences[name]._reinitialize({connection: this,
91
-            roomState: states[name]});
89
+        this.conferences[name]._init({roomState: states[name]});
90
+        this.conferences[name].join();
92
     }
91
     }
93
 }
92
 }
94
 
93
 

+ 6
- 10
modules/statistics/statistics.js View File

21
 // downloading their API as soon as possible and (2) do the downloading
21
 // downloading their API as soon as possible and (2) do the downloading
22
 // asynchronously.
22
 // asynchronously.
23
 function loadCallStatsAPI() {
23
 function loadCallStatsAPI() {
24
-    if(!isCallstatsLoaded)
24
+    if(!isCallstatsLoaded) {
25
         ScriptUtil.loadScript(
25
         ScriptUtil.loadScript(
26
                 'https://api.callstats.io/static/callstats.min.js',
26
                 'https://api.callstats.io/static/callstats.min.js',
27
                 /* async */ true,
27
                 /* async */ true,
28
                 /* prepend */ true);
28
                 /* prepend */ true);
29
-    isCallstatsLoaded = true;
29
+        isCallstatsLoaded = true;
30
+    }
30
     // FIXME At the time of this writing, we hope that the callstats.io API will
31
     // FIXME At the time of this writing, we hope that the callstats.io API will
31
     // have loaded by the time we needed it (i.e. CallStats.init is invoked).
32
     // have loaded by the time we needed it (i.e. CallStats.init is invoked).
32
 }
33
 }
221
  * Removes the callstats.io instances.
222
  * Removes the callstats.io instances.
222
  */
223
  */
223
 Statistics.prototype.stopCallStats = function () {
224
 Statistics.prototype.stopCallStats = function () {
224
-    if(this.callStatsIntegrationEnabled && this.callstats) {
225
-        var callstatsList = Statistics.callsStatsInstances;
226
-        for(var i = 0;i < callstatsList.length; i++) {
227
-            if(this.callstats === callstatsList[i]) {
228
-                Statistics.callsStatsInstances.splice(i, 1);
229
-                break;
230
-            }
231
-        }
225
+    if(this.callstats) {
226
+        var index = Statistics.callsStatsInstances.indexOf(this.callstats);
227
+        Statistics.callsStatsInstances.splice(index, 1);
232
         this.callstats = null;
228
         this.callstats = null;
233
         CallStats.dispose();
229
         CallStats.dispose();
234
     }
230
     }

+ 3
- 4
modules/xmpp/JingleSessionPC.js View File

1103
             error.source = request.tree();
1103
             error.source = request.tree();
1104
         }
1104
         }
1105
 
1105
 
1106
-        // Commented to fix JSON.stringify(error) exception for
1107
-        // circular dependancies when we print that error.
1108
-        // FIXME: Maybe we can include
1109
-        // part of the session object
1106
+        // Commented to fix JSON.stringify(error) exception for circular
1107
+        // dependancies when we print that error.
1108
+        // FIXME: Maybe we can include part of the session object
1110
         // error.session = this;
1109
         // error.session = this;
1111
 
1110
 
1112
         logger.error("Jingle error", error);
1111
         logger.error("Jingle error", error);

+ 1
- 12
modules/xmpp/xmpp.js View File

60
 
60
 
61
 /**
61
 /**
62
  * Reloads the XMPP module
62
  * Reloads the XMPP module
63
- * @param options {object} options to be overriden
64
  */
63
  */
65
-XMPP.prototype.reload = function (options) {
66
-    if(!options)
67
-        options = {};
68
-    if(!this.options) {
69
-        this.options = options;
70
-    } else {
71
-        // Override config options
72
-        for(var key in options)
73
-            this.options[key] = options[key] || this.options[key];
74
-    }
75
-
64
+XMPP.prototype.reload = function () {
76
     this.disconnect();
65
     this.disconnect();
77
     this.connection.pause();
66
     this.connection.pause();
78
     this.connection = createConnection(this.options.bosh, this.token);
67
     this.connection = createConnection(this.options.bosh, this.token);

Loading…
Cancel
Save