collab_client: Defer sending messages until connected

This avoids filling the server logs with "Dropping pre-CLIENT_READY
message" error messages.
rhansen-collab_client
Richard Hansen 2021-03-30 18:32:37 -04:00
parent 1ff228391d
commit a18f5de0fc
1 changed files with 5 additions and 4 deletions

View File

@ -167,7 +167,8 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
handleUserChanges();
};
const sendMessage = (msg) => {
const sendMessage = async (msg) => {
await connectedGate;
getSocket().json.send(
{
type: 'COLLABROOM',
@ -326,7 +327,7 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
userSet[userId] = userInfo;
tellAceActiveAuthorInfo(userInfo);
if (!getSocket()) return;
sendMessage(
await sendMessage(
{
type: 'USERINFO_UPDATE',
userInfo,
@ -398,8 +399,8 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
return array;
};
const sendClientMessage = (msg) => {
sendMessage(
const sendClientMessage = async (msg) => {
await sendMessage(
{
type: 'CLIENT_MESSAGE',
payload: msg,