Переглянути джерело

Sends endpoint information in COLIBRI messages (in 'endpoint' children

of 'conference').
j8
Boris Grozev 11 роки тому
джерело
коміт
256694b966
2 змінених файлів з 100 додано та 1 видалено
  1. 16
    0
      app.js
  2. 84
    1
      libs/colibri/colibri.focus.js

+ 16
- 0
app.js Переглянути файл

632
 
632
 
633
     if (Object.keys(connection.emuc.members).length < 1) {
633
     if (Object.keys(connection.emuc.members).length < 1) {
634
         focus = new ColibriFocus(connection, config.hosts.bridge);
634
         focus = new ColibriFocus(connection, config.hosts.bridge);
635
+        if (nickname !== null) {
636
+            focus.setEndpointDisplayName(connection.emuc.myroomjid,
637
+                                         nickname);
638
+        }
635
         showRecordingButton(false);
639
         showRecordingButton(false);
636
     }
640
     }
637
 
641
 
710
             && !sessionTerminated) {
714
             && !sessionTerminated) {
711
         console.log('welcome to our new focus... myself');
715
         console.log('welcome to our new focus... myself');
712
         focus = new ColibriFocus(connection, config.hosts.bridge);
716
         focus = new ColibriFocus(connection, config.hosts.bridge);
717
+        if (nickname !== null) {
718
+            focus.setEndpointDisplayName(connection.emuc.myroomjid,
719
+                                         nickname);
720
+        }
713
 
721
 
714
         if (Object.keys(connection.emuc.members).length > 0) {
722
         if (Object.keys(connection.emuc.members).length > 0) {
715
             focus.makeConference(Object.keys(connection.emuc.members));
723
             focus.makeConference(Object.keys(connection.emuc.members));
723
         // problems with reinit
731
         // problems with reinit
724
         disposeConference();
732
         disposeConference();
725
         focus = new ColibriFocus(connection, config.hosts.bridge);
733
         focus = new ColibriFocus(connection, config.hosts.bridge);
734
+        if (nickname !== null) {
735
+            focus.setEndpointDisplayName(connection.emuc.myroomjid,
736
+                                         nickname);
737
+        }
726
         showRecordingButton(false);
738
         showRecordingButton(false);
727
     }
739
     }
728
     if (connection.emuc.getPrezi(jid)) {
740
     if (connection.emuc.getPrezi(jid)) {
776
                 'participant_' + Strophe.getResourceFromJid(jid),
788
                 'participant_' + Strophe.getResourceFromJid(jid),
777
                 info.displayName);
789
                 info.displayName);
778
     }
790
     }
791
+
792
+    if (focus !== null && info.displayName !== null) {
793
+        focus.setEndpointDisplayName(jid, info.displayName);
794
+    }
779
 });
795
 });
780
 
796
 
781
 $(document).bind('passwordrequired.muc', function (event, jid) {
797
 $(document).bind('passwordrequired.muc', function (event, jid) {

+ 84
- 1
libs/colibri/colibri.focus.js Переглянути файл

84
     this.wait = true;
84
     this.wait = true;
85
 
85
 
86
     this.recordingEnabled = false;
86
     this.recordingEnabled = false;
87
+
88
+    // stores information about the endpoints (i.e. display names) to
89
+    // be sent to the videobridge.
90
+    this.endpointsInfo = null;
87
 }
91
 }
88
 
92
 
89
 // creates a conferences with an initial set of peers
93
 // creates a conferences with an initial set of peers
176
 // the new recording state, according to the IQ.
180
 // the new recording state, according to the IQ.
177
 ColibriFocus.prototype.setRecording = function(state, token, callback) {
181
 ColibriFocus.prototype.setRecording = function(state, token, callback) {
178
     var self = this;
182
     var self = this;
179
-    var elem = $iq({to: this.bridgejid, type: 'get'});
183
+    var elem = $iq({to: this.bridgejid, type: 'set'});
180
     elem.c('conference', {
184
     elem.c('conference', {
181
         xmlns: 'http://jitsi.org/protocol/colibri',
185
         xmlns: 'http://jitsi.org/protocol/colibri',
182
         id: this.confid
186
         id: this.confid
199
     );
203
     );
200
 };
204
 };
201
 
205
 
206
+/*
207
+ * Updates the display name for an endpoint with a specific jid.
208
+ * jid: the jid associated with the endpoint.
209
+ * displayName: the new display name for the endpoint.
210
+ */
211
+ColibriFocus.prototype.setEndpointDisplayName = function(jid, displayName) {
212
+    var endpointId = jid.substr(1 + jid.lastIndexOf('/'));
213
+    var update = false;
214
+
215
+    if (this.endpointsInfo === null) {
216
+       this.endpointsInfo = {};
217
+    }
218
+
219
+    var endpointInfo = this.endpointsInfo[endpointId];
220
+    if ('undefined' === typeof endpointInfo) {
221
+        endpointInfo = this.endpointsInfo[endpointId] = {};
222
+    }
223
+
224
+    if (endpointInfo['displayname'] !== displayName) {
225
+        endpointInfo['displayname'] = displayName;
226
+        update = true;
227
+    }
228
+
229
+    if (update) {
230
+        this.updateEndpoints();
231
+    }
232
+};
233
+
234
+/*
235
+ * Sends a colibri message to the bridge that contains the
236
+ * current endpoints and their display names.
237
+ */
238
+ColibriFocus.prototype.updateEndpoints = function() {
239
+    if (this.confid === null
240
+        || this.endpointsInfo === null) {
241
+        return;
242
+    }
243
+
244
+    if (this.confid === 0) {
245
+        // the colibri conference is currently initiating
246
+        var self = this;
247
+        window.setTimeout(function() { self.updateEndpoints()}, 1000);
248
+        return;
249
+    }
250
+
251
+    var elem = $iq({to: this.bridgejid, type: 'set'});
252
+    elem.c('conference', {
253
+        xmlns: 'http://jitsi.org/protocol/colibri',
254
+        id: this.confid
255
+    });
256
+
257
+    for (var id in this.endpointsInfo) {
258
+        elem.c('endpoint');
259
+        elem.attrs({ id: id,
260
+                     displayname: this.endpointsInfo[id]['displayname']
261
+        });
262
+        elem.up();
263
+    }
264
+
265
+    //elem.up(); //conference
266
+
267
+    this.connection.sendIQ(
268
+        elem,
269
+        function (result) {},
270
+        function (error) { console.warn(error); }
271
+    );
272
+};
273
+
202
 ColibriFocus.prototype._makeConference = function () {
274
 ColibriFocus.prototype._makeConference = function () {
203
     var self = this;
275
     var self = this;
204
     var elem = $iq({ to: this.bridgejid, type: 'get' });
276
     var elem = $iq({ to: this.bridgejid, type: 'get' });
235
         }
307
         }
236
         elem.up(); // end of content
308
         elem.up(); // end of content
237
     });
309
     });
310
+
311
+    if (this.endpointsInfo !== null) {
312
+        for (var id in this.endpointsInfo) {
313
+            elem.c('endpoint');
314
+            elem.attrs({ id: id,
315
+                         displayname: this.endpointsInfo[id]['displayname']
316
+            });
317
+            elem.up();
318
+        }
319
+    }
320
+
238
     /*
321
     /*
239
     var localSDP = new SDP(this.peerconnection.localDescription.sdp);
322
     var localSDP = new SDP(this.peerconnection.localDescription.sdp);
240
     localSDP.media.forEach(function (media, channel) {
323
     localSDP.media.forEach(function (media, channel) {

Завантаження…
Відмінити
Зберегти