diff --git a/react/features/local-recording/controller/RecordingController.js b/react/features/local-recording/controller/RecordingController.js index dd64f151c..915d880e9 100644 --- a/react/features/local-recording/controller/RecordingController.js +++ b/react/features/local-recording/controller/RecordingController.js @@ -21,6 +21,20 @@ const COMMAND_START = 'localRecStart'; */ const COMMAND_STOP = 'localRecStop'; +/** + * One-time command used to trigger the moderator to resend the commands. + * This is a workaround for newly-joined clients to receive remote presence. + */ +const COMMAND_PING = 'localRecPing'; + +/** + * One-time command sent upon receiving a {@code COMMAND_PING}. + * Only the moderator sends this command. + * This command does not carry any information itself, but rather forces the + * XMPP server to resend the remote presence. + */ +const COMMAND_PONG = 'localRecPong'; + /** * Participant property key for local recording stats. */ @@ -167,6 +181,7 @@ class RecordingController { this._updateStats = this._updateStats.bind(this); this._onStartCommand = this._onStartCommand.bind(this); this._onStopCommand = this._onStopCommand.bind(this); + this._onPingCommand = this._onPingCommand.bind(this); this._doStartRecording = this._doStartRecording.bind(this); this._doStopRecording = this._doStopRecording.bind(this); this.registerEvents = this.registerEvents.bind(this); @@ -189,8 +204,13 @@ class RecordingController { .addCommandListener(COMMAND_STOP, this._onStopCommand); this._conference .addCommandListener(COMMAND_START, this._onStartCommand); + this._conference + .addCommandListener(COMMAND_PING, this._onPingCommand); this._registered = true; } + if (!this._conference.isModerator()) { + this._conference.sendCommandOnce(COMMAND_PING, {}); + } } } @@ -225,7 +245,7 @@ class RecordingController { */ stopRecording() { if (this._conference) { - if (this._conference.isModerator) { + if (this._conference.isModerator()) { this._conference.removeCommand(COMMAND_START); this._conference.sendCommand(COMMAND_STOP, { attributes: { @@ -409,6 +429,21 @@ class RecordingController { } } + _onPingCommand: () => void; + + /** + * Callback function for XMPP event. + * + * @private + * @returns {void} + */ + _onPingCommand() { + if (this._conference.isModerator()) { + logger.log('Received ping, sending pong.'); + this._conference.sendCommandOnce(COMMAND_PONG, {}); + } + } + /** * Generates a token that can be used to distinguish each * recording session.