Просмотр исходного кода

Merge pull request #184 from jitsi/revert-181-dc_stats

Revert "Implements interfaces for data channel communication"
dev1
bgrozev 9 лет назад
Родитель
Сommit
d61dd7101c
7 измененных файлов: 40 добавлений и 99 удалений
  1. 0
    10
      JitsiConference.js
  2. 11
    11
      JitsiConferenceEventManager.js
  3. 1
    7
      JitsiConferenceEvents.js
  4. 3
    5
      doc/API.md
  5. 24
    49
      modules/RTC/DataChannels.js
  6. 0
    10
      modules/RTC/RTC.js
  7. 1
    7
      service/RTC/RTCEvents.js

+ 0
- 10
JitsiConference.js Просмотреть файл

@@ -1228,14 +1228,4 @@ JitsiConference.prototype._fireIncompatibleVersionsEvent = function () {
1228 1228
         JitsiConferenceErrors.INCOMPATIBLE_SERVER_VERSIONS);
1229 1229
 };
1230 1230
 
1231
-/**
1232
- * Sends broadcast message via the datachannels.
1233
- * @param payload {object} the payload of the message.
1234
- */
1235
-JitsiConference.prototype.sendDataChannelBroadcast = function (payload) {
1236
-    if(this.rtc) {
1237
-        this.rtc.sendDataChannelBroadcast(payload);
1238
-    }
1239
-}
1240
-
1241 1231
 module.exports = JitsiConference;

+ 11
- 11
JitsiConferenceEventManager.js Просмотреть файл

@@ -394,10 +394,6 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
394 394
  */
395 395
 JitsiConferenceEventManager.prototype.setupRTCListeners = function () {
396 396
     var conference = this.conference;
397
-
398
-    this.rtcForwarder = new EventEmitterForwarder(conference.rtc,
399
-        this.conference.eventEmitter);
400
-
401 397
     conference.rtc.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED,
402 398
         function (id) {
403 399
             if(conference.lastDominantSpeaker !== id && conference.room) {
@@ -417,19 +413,23 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function () {
417 413
         conference.room.connectionTimes["data.channel.opened"] = now;
418 414
     });
419 415
 
420
-    this.rtcForwarder.forward(RTCEvents.LASTN_CHANGED,
421
-        JitsiConferenceEvents.IN_LAST_N_CHANGED);
416
+    conference.rtc.addListener(RTCEvents.LASTN_CHANGED,
417
+        function (oldValue, newValue) {
418
+            conference.eventEmitter.emit(
419
+                JitsiConferenceEvents.IN_LAST_N_CHANGED, oldValue, newValue);
420
+        });
422 421
 
423
-    this.rtcForwarder.forward(RTCEvents.LASTN_ENDPOINT_CHANGED,
424
-        JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED);
422
+    conference.rtc.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
423
+        function (lastNEndpoints, endpointsEnteringLastN) {
424
+            conference.eventEmitter.emit(
425
+                JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
426
+                lastNEndpoints, endpointsEnteringLastN);
427
+        });
425 428
 
426 429
     conference.rtc.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED,
427 430
         function (devices) {
428 431
             conference.room.updateDeviceAvailability(devices);
429 432
         });
430
-
431
-    this.rtcForwarder.forward(RTCEvents.DATACHANNEL_ENDPOINT_MESSAGE_RECEIVED,
432
-        JitsiConferenceEvents.DATACHANNEL_ENDPOINT_MESSAGE_RECEIVED);
433 433
 };
434 434
 
435 435
 /**

+ 1
- 7
JitsiConferenceEvents.js Просмотреть файл

@@ -135,13 +135,7 @@ var JitsiConferenceEvents = {
135 135
      * Indicates that a the value of a specific property of a specific
136 136
      * participant has changed.
137 137
      */
138
-    PARTICIPANT_PROPERTY_CHANGED: "conference.participant_property_changed",
139
-    /**
140
-     * Indicates that a message from another participant is received on
141
-     * data channel.
142
-     */
143
-    DATACHANNEL_ENDPOINT_MESSAGE_RECEIVED:
144
-        "conference.datachannel_endpoint_message_received"
138
+    PARTICIPANT_PROPERTY_CHANGED: "conference.participant_property_changed"
145 139
 };
146 140
 
147 141
 module.exports = JitsiConferenceEvents;

+ 3
- 5
doc/API.md Просмотреть файл

@@ -118,8 +118,6 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
118 118
         - AVAILABLE_DEVICES_CHANGED - notifies that available participant devices changed (camera or microphone was added or removed) (parameters - id(string), devices(JS object with 2 properties - audio(boolean), video(boolean)))
119 119
         - CONNECTION_STATS - New local connection statistics are received. (parameters - stats(object))
120 120
         - AUTH_STATUS_CHANGED - notifies that authentication is enabled or disabled, or local user authenticated (logged in). (parameters - isAuthEnabled(boolean), authIdentity(string))
121
-        - DATACHANNEL_ENDPOINT_MESSAGE_RECEIVED - notifies that a new message
122
-        from another participant is received on a data channel.
123 121
 
124 122
     2. connection
125 123
         - CONNECTION_FAILED - indicates that the server connection failed.
@@ -172,10 +170,10 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
172 170
         - CHROME_EXTENSION_USER_CANCELED - an error which indicates that user canceled screen sharing window selection dialog in jidesha extension for Chrome.
173 171
         - CHROME_EXTENSION_INSTALLATION_ERROR - an error which indicates that the jidesha extension for Chrome is failed to install.
174 172
         - FIREFOX_EXTENSION_NEEDED - An error which indicates that the jidesha extension for Firefox is needed to proceed with screen sharing, and that it is not installed.
175
-
173
+        
176 174
 * ```JitsiMeetJS.errorTypes``` - constructors for Error instances that can be produced by library. Are useful for checks like ```error instanceof JitsiMeetJS.errorTypes.JitsiTrackError```. Following Errors are available:
177 175
     1. ```JitsiTrackError``` - Error that happened to a JitsiTrack.
178
-
176
+        
179 177
 * ```JitsiMeetJS.logLevels``` - object with the log levels:
180 178
     1. TRACE
181 179
     2. DEBUG
@@ -383,7 +381,7 @@ We have the following methods for controling the tracks:
383 381
 
384 382
 JitsiTrackError
385 383
 ======
386
-The object represents error that happened to a JitsiTrack. Is inherited from JavaScript base ```Error``` object,
384
+The object represents error that happened to a JitsiTrack. Is inherited from JavaScript base ```Error``` object, 
387 385
 so ```"name"```, ```"message"``` and ```"stack"``` properties are available. For GUM-related errors,
388 386
 exposes additional ```"gum"``` property, which is an object with following properties:
389 387
  - error - original GUM error

+ 24
- 49
modules/RTC/DataChannels.js Просмотреть файл

@@ -143,10 +143,6 @@ DataChannels.prototype.onDataChannel = function (event) {
143 143
                     lastNEndpoints, endpointsEnteringLastN, obj);
144 144
                 self.eventEmitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED,
145 145
                     lastNEndpoints, endpointsEnteringLastN, obj);
146
-            } else if("EndpointMessage" === colibriClass) {
147
-                self.eventEmitter.emit(
148
-                    RTCEvents.DATACHANNEL_ENDPOINT_MESSAGE_RECEIVED,
149
-                    obj.msgPayload);
150 146
             }
151 147
             else {
152 148
                 logger.debug("Data channel JSON-formatted message: ", obj);
@@ -208,22 +204,34 @@ DataChannels.prototype._onXXXEndpointChanged = function (xxx, userResource) {
208 204
     var tail = xxx.substring(1);
209 205
     var lower = head.toLowerCase() + tail;
210 206
     var upper = head.toUpperCase() + tail;
211
-    logger.log(
212
-            'sending ' + lower
213
-                + ' endpoint changed notification to the bridge: ',
214
-            userResource);
215
-
216
-    var jsonObject = {};
217
-
218
-    jsonObject.colibriClass = (upper + 'EndpointChangedEvent');
219
-    jsonObject[lower + "Endpoint"]
220
-        = (userResource ? userResource : null);
221
-
222
-    this.send(jsonObject);
223 207
 
224 208
     // Notify Videobridge about the specified endpoint change.
225 209
     logger.log(lower + ' endpoint changed: ', userResource);
210
+    this._some(function (dataChannel) {
211
+        if (dataChannel.readyState == 'open') {
212
+            logger.log(
213
+                    'sending ' + lower
214
+                        + ' endpoint changed notification to the bridge: ',
215
+                    userResource);
216
+
217
+            var jsonObject = {};
218
+
219
+            jsonObject.colibriClass = (upper + 'EndpointChangedEvent');
220
+            jsonObject[lower + "Endpoint"]
221
+                = (userResource ? userResource : null);
222
+            try {
223
+                dataChannel.send(JSON.stringify(jsonObject));
224
+            } catch (e) {
225
+                // FIXME: Maybe we should check if the conference is left
226
+                // before calling _onXXXEndpointChanged method.
227
+                // FIXME: We should check if we are disposing correctly the
228
+                // data channels.
229
+                logger.warn(e);
230
+            }
226 231
 
232
+            return true;
233
+        }
234
+    });
227 235
 };
228 236
 
229 237
 DataChannels.prototype._some = function (callback, thisArg) {
@@ -239,37 +247,4 @@ DataChannels.prototype._some = function (callback, thisArg) {
239 247
     }
240 248
 };
241 249
 
242
-/**
243
- * Sends passed object via the first found open datachannel
244
- * @param jsonObject {object} the object that will be sent
245
- */
246
-DataChannels.prototype.send = function (jsonObject) {
247
-    this._some(function (dataChannel) {
248
-        if (dataChannel.readyState == 'open') {
249
-            dataChannel.send(JSON.stringify(jsonObject));
250
-            return true;
251
-        }
252
-    });
253
-}
254
-
255
-/**
256
- * Sends broadcast message via the datachannels.
257
- * @param payload {object} the payload of the message.
258
- */
259
-DataChannels.prototype.sendBroadcastMessage = function (payload) {
260
-    var jsonObject = {};
261
-
262
-    jsonObject.colibriClass = "EndpointMessage";
263
-    jsonObject.to = "";
264
-    // following the same format for the payload in order to be able to
265
-    // recognise the message on the receiving side.
266
-    jsonObject.msgPayload = {
267
-        colibriClass: "EndpointMessage",
268
-        to: "",
269
-        msgPayload: payload
270
-    };
271
-
272
-    this.send(jsonObject);
273
-}
274
-
275 250
 module.exports = DataChannels;

+ 0
- 10
modules/RTC/RTC.js Просмотреть файл

@@ -485,14 +485,4 @@ RTC.prototype.handleRemoteTrackVideoTypeChanged = function (value, from) {
485 485
     }
486 486
 }
487 487
 
488
-/**
489
- * Sends broadcast message via the datachannels.
490
- * @param payload {object} the payload of the message.
491
- */
492
-RTC.prototype.sendDataChannelBroadcast = function (payload) {
493
-    if(this.dataChannels) {
494
-        this.dataChannels.sendBroadcastMessage(payload);
495
-    }
496
-}
497
-
498 488
 module.exports = RTC;

+ 1
- 7
service/RTC/RTCEvents.js Просмотреть файл

@@ -8,13 +8,7 @@ var RTCEvents = {
8 8
     TRACK_ATTACHED: "rtc.track_attached",
9 9
     AUDIO_OUTPUT_DEVICE_CHANGED: "rtc.audio_output_device_changed",
10 10
     DEVICE_LIST_CHANGED: "rtc.device_list_changed",
11
-    DEVICE_LIST_AVAILABLE: "rtc.device_list_available",
12
-    /**
13
-     * Indicates that a message from another participant is received on
14
-     * data channel.
15
-     */
16
-    DATACHANNEL_ENDPOINT_MESSAGE_RECEIVED:
17
-        "rtc.datachannel_endpoint_message_received"
11
+    DEVICE_LIST_AVAILABLE: "rtc.device_list_available"
18 12
 };
19 13
 
20 14
 module.exports = RTCEvents;

Загрузка…
Отмена
Сохранить