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,6 +21,20 @@ const COMMAND_START = 'localRecStart';
21 21
  */
22 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 39
  * Participant property key for local recording stats.
26 40
  */
@@ -167,6 +181,7 @@ class RecordingController {
167 181
         this._updateStats = this._updateStats.bind(this);
168 182
         this._onStartCommand = this._onStartCommand.bind(this);
169 183
         this._onStopCommand = this._onStopCommand.bind(this);
184
+        this._onPingCommand = this._onPingCommand.bind(this);
170 185
         this._doStartRecording = this._doStartRecording.bind(this);
171 186
         this._doStopRecording = this._doStopRecording.bind(this);
172 187
         this.registerEvents = this.registerEvents.bind(this);
@@ -189,8 +204,13 @@ class RecordingController {
189 204
                     .addCommandListener(COMMAND_STOP, this._onStopCommand);
190 205
                 this._conference
191 206
                     .addCommandListener(COMMAND_START, this._onStartCommand);
207
+                this._conference
208
+                    .addCommandListener(COMMAND_PING, this._onPingCommand);
192 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,7 +245,7 @@ class RecordingController {
225 245
      */
226 246
     stopRecording() {
227 247
         if (this._conference) {
228
-            if (this._conference.isModerator) {
248
+            if (this._conference.isModerator()) {
229 249
                 this._conference.removeCommand(COMMAND_START);
230 250
                 this._conference.sendCommand(COMMAND_STOP, {
231 251
                     attributes: {
@@ -409,6 +429,21 @@ class RecordingController {
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 448
      * Generates a token that can be used to distinguish each
414 449
      * recording session.

Loading…
Cancel
Save