From 1ff228391da87ab4ef5b3bc242857fb2d5669201 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Tue, 30 Mar 2021 18:18:02 -0400 Subject: [PATCH] collab_client: Set CONNECTED after sending CLIENT_READY This makes it possible to defer actions until after the CLIENT_READY message is sent to the server. --- src/static/js/pad.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index f1bac0616..136b7e9a1 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -215,6 +215,10 @@ const sendClientReady = (isReconnect, messageType) => { } socket.json.send(msg); + + // If this is a reconnect then the server won't send another CLIENT_VARS because we are already + // configured and ready to send arbitrary messages to the server. + if (isReconnect) pad.collabClient.setChannelState('CONNECTED'); }; const handshake = () => { @@ -237,10 +241,6 @@ const handshake = () => { }); socket.on('reconnect', () => { - // pad.collabClient might be null if the hanshake failed (or it never got that far). - if (pad.collabClient != null) { - pad.collabClient.setChannelState('CONNECTED'); - } sendClientReady(receivedClientVars); });