Browse Source

Temp fix: newly joined clients miss the commands

When newly joined clients register for XMPP events upon
CONFERENCE_JOINED, those events that is carried by presence (e.g. START_COMMAND) was
already fired.
Temporary solution is to let the client send a ping message after
registering XMPP event listeners. The moderator will respond with
pong, which forces the presence to be resent.
master
Radium Zheng 7 years ago
parent
commit
f8c01646c7
1 changed files with 36 additions and 1 deletions
  1. 36
    1
      react/features/local-recording/controller/RecordingController.js

+ 36
- 1
react/features/local-recording/controller/RecordingController.js View File

21
  */
21
  */
22
 const COMMAND_STOP = 'localRecStop';
22
 const COMMAND_STOP = 'localRecStop';
23
 
23
 
24
+/**
25
+ * One-time command used to trigger the moderator to resend the commands.
26
+ * This is a workaround for newly-joined clients to receive remote presence.
27
+ */
28
+const COMMAND_PING = 'localRecPing';
29
+
30
+/**
31
+ * One-time command sent upon receiving a {@code COMMAND_PING}.
32
+ * Only the moderator sends this command.
33
+ * This command does not carry any information itself, but rather forces the
34
+ * XMPP server to resend the remote presence.
35
+ */
36
+const COMMAND_PONG = 'localRecPong';
37
+
24
 /**
38
 /**
25
  * Participant property key for local recording stats.
39
  * Participant property key for local recording stats.
26
  */
40
  */
167
         this._updateStats = this._updateStats.bind(this);
181
         this._updateStats = this._updateStats.bind(this);
168
         this._onStartCommand = this._onStartCommand.bind(this);
182
         this._onStartCommand = this._onStartCommand.bind(this);
169
         this._onStopCommand = this._onStopCommand.bind(this);
183
         this._onStopCommand = this._onStopCommand.bind(this);
184
+        this._onPingCommand = this._onPingCommand.bind(this);
170
         this._doStartRecording = this._doStartRecording.bind(this);
185
         this._doStartRecording = this._doStartRecording.bind(this);
171
         this._doStopRecording = this._doStopRecording.bind(this);
186
         this._doStopRecording = this._doStopRecording.bind(this);
172
         this.registerEvents = this.registerEvents.bind(this);
187
         this.registerEvents = this.registerEvents.bind(this);
189
                     .addCommandListener(COMMAND_STOP, this._onStopCommand);
204
                     .addCommandListener(COMMAND_STOP, this._onStopCommand);
190
                 this._conference
205
                 this._conference
191
                     .addCommandListener(COMMAND_START, this._onStartCommand);
206
                     .addCommandListener(COMMAND_START, this._onStartCommand);
207
+                this._conference
208
+                    .addCommandListener(COMMAND_PING, this._onPingCommand);
192
                 this._registered = true;
209
                 this._registered = true;
193
             }
210
             }
211
+            if (!this._conference.isModerator()) {
212
+                this._conference.sendCommandOnce(COMMAND_PING, {});
213
+            }
194
         }
214
         }
195
     }
215
     }
196
 
216
 
225
      */
245
      */
226
     stopRecording() {
246
     stopRecording() {
227
         if (this._conference) {
247
         if (this._conference) {
228
-            if (this._conference.isModerator) {
248
+            if (this._conference.isModerator()) {
229
                 this._conference.removeCommand(COMMAND_START);
249
                 this._conference.removeCommand(COMMAND_START);
230
                 this._conference.sendCommand(COMMAND_STOP, {
250
                 this._conference.sendCommand(COMMAND_STOP, {
231
                     attributes: {
251
                     attributes: {
409
         }
429
         }
410
     }
430
     }
411
 
431
 
432
+    _onPingCommand: () => void;
433
+
434
+    /**
435
+     * Callback function for XMPP event.
436
+     *
437
+     * @private
438
+     * @returns {void}
439
+     */
440
+    _onPingCommand() {
441
+        if (this._conference.isModerator()) {
442
+            logger.log('Received ping, sending pong.');
443
+            this._conference.sendCommandOnce(COMMAND_PONG, {});
444
+        }
445
+    }
446
+
412
     /**
447
     /**
413
      * Generates a token that can be used to distinguish each
448
      * Generates a token that can be used to distinguish each
414
      * recording session.
449
      * recording session.

Loading…
Cancel
Save