diff --git a/app/scenes/Document/components/SocketPresence.js b/app/scenes/Document/components/SocketPresence.js index b3ea5ec8e6..e1733fa71c 100644 --- a/app/scenes/Document/components/SocketPresence.js +++ b/app/scenes/Document/components/SocketPresence.js @@ -22,15 +22,22 @@ export default function SocketPresence(props: Props) { // ); React.useEffect(() => { + console.log("useEffect", context); if (!context) return; const emitJoin = () => { if (!context) return; + console.log("JOIN"); context.emit("join", { documentId: props.documentId }); }; context.on("authenticated", () => { - emitJoin(); + console.log("authenticated"); + + // wait just a hair to join the presence room, this is mainly for a + // development race condition where the join event could be emitted before + // the listener is added on the server + setTimeout(emitJoin, 100); }); if (context.authenticated) { diff --git a/server/main.js b/server/main.js index c2485581b7..68c97dc456 100644 --- a/server/main.js +++ b/server/main.js @@ -112,7 +112,7 @@ SocketAuth(io, { // allow the client to request to join rooms socket.on("join", async (event) => { - log("join", JSON.stringify(event)); + log("join", event.documentId, socket.id); // user is joining a collection channel, because their permissions have // changed, granting them access. if (event.collectionId) { @@ -139,6 +139,7 @@ SocketAuth(io, { // new logic for multiplayer editing completely changes "presence" // detection and propagation, so split at a high-level here. if (team.multiplayerEditor) { + log("joined multiplayer", socket.id); socket.join(room, () => { socket.emit("user.join", { userId: user.id,