Quellcode durchsuchen

fix(RTC): cache and send pinned endpoint

Do the same which was done for the selected endpoint. That is if
an endpoint is pinned, before data channels are available then the value
should be cached and sent as soon as they are opened.
master
paweldomas vor 8 Jahren
Ursprung
Commit
1780a1063a
1 geänderte Dateien mit 33 neuen und 13 gelöschten Zeilen
  1. 33
    13
      modules/RTC/RTC.js

+ 33
- 13
modules/RTC/RTC.js Datei anzeigen

@@ -98,11 +98,30 @@ export default class RTC extends Listenable {
98 98
          */
99 99
         this._lastN = null;
100 100
 
101
-        // Defines the last N endpoints list. It can be null or an array once
102
-        // initialised with a datachannel last N event.
103
-        // @type {Array<string>|null}
101
+        /**
102
+         * Defines the last N endpoints list. It can be null or an array once
103
+         * initialised with a datachannel last N event.
104
+         * @type {Array<string>|null}
105
+         * @private
106
+         */
104 107
         this._lastNEndpoints = null;
105 108
 
109
+        /**
110
+         * The endpoint ID of currently pinned participant or <tt>null</tt> if
111
+         * no user is pinned.
112
+         * @type {string|null}
113
+         * @private
114
+         */
115
+        this._pinnedEndpoint = null;
116
+
117
+        /**
118
+         * The endpoint ID of currently selected participant or <tt>null</tt> if
119
+         * no user is selected.
120
+         * @type {string|null}
121
+         * @private
122
+         */
123
+        this._selectedEndpoint = null;
124
+
106 125
         // The last N change listener.
107 126
         this._lastNChangeListener = this._onLastNChanged.bind(this);
108 127
 
@@ -165,14 +184,17 @@ export default class RTC extends Listenable {
165 184
                 // about video selections so that it can do adaptive simulcast,
166 185
                 // we want the notification to trigger even if userJid
167 186
                 // is undefined, or null.
168
-                // XXX why do we not do the same for pinned endpoints?
169 187
                 try {
188
+                    this.dataChannels.sendPinnedEndpointMessage(
189
+                        this._pinnedEndpoint);
170 190
                     this.dataChannels.sendSelectedEndpointMessage(
171
-                        this.selectedEndpoint);
191
+                        this._selectedEndpoint);
172 192
                 } catch (error) {
173 193
                     GlobalOnErrorHandler.callErrorHandler(error);
174
-                    logger.error('Cannot sendSelectedEndpointMessage ',
175
-                        this.selectedEndpoint, '. Error: ', error);
194
+                    logger.error(
195
+                        `Cannot send selected(${this._selectedEndpoint})`
196
+                        + `pinned(${this._pinnedEndpoint}) endpoint message.`,
197
+                        error);
176 198
                 }
177 199
 
178 200
                 this.removeListener(RTCEvents.DATA_CHANNEL_OPEN,
@@ -247,7 +269,7 @@ export default class RTC extends Listenable {
247 269
      */
248 270
     selectEndpoint(id) {
249 271
         // cache the value if channel is missing, till we open it
250
-        this.selectedEndpoint = id;
272
+        this._selectedEndpoint = id;
251 273
         if (this.dataChannels && this.dataChannelsOpen) {
252 274
             this.dataChannels.sendSelectedEndpointMessage(id);
253 275
         }
@@ -262,12 +284,10 @@ export default class RTC extends Listenable {
262 284
      * fails.
263 285
      */
264 286
     pinEndpoint(id) {
265
-        if (this.dataChannels) {
287
+        // cache the value if channel is missing, till we open it
288
+        this._pinnedEndpoint = id;
289
+        if (this.dataChannels && this.dataChannelsOpen) {
266 290
             this.dataChannels.sendPinnedEndpointMessage(id);
267
-        } else {
268
-            // FIXME: cache value while there is no data channel created
269
-            // and send the cached state once channel is created
270
-            throw new Error('Data channels support is disabled!');
271 291
         }
272 292
     }
273 293
 

Laden…
Abbrechen
Speichern