Skip to content

Commit

Permalink
make ws connection and get user synchronized. fix #156
Browse files Browse the repository at this point in the history
  • Loading branch information
petertheprocess committed May 12, 2024
1 parent 9533eee commit f0c58df
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/components/views/Lobby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ const Lobby = () => {
onLobbyInfoReceived
);
stompClientRef.current?.send(
"/app/message/lobby/info", { receiptId: "" }
"/app/message/lobby/info",
{
receiptId: "",
token: sessionStorage.getItem("token")
}
);


Expand Down Expand Up @@ -201,12 +205,16 @@ const Lobby = () => {
navigate("/login");
};

// make sure user was fetched before set timeoutId
fetchData().catch(error => {
handleError(error);
});

connectWebSocket();
// make sure the ws connection was opened after fetching data
fetchData()
.then(
() => {
connectWebSocket();
}
)
.catch(error => {
handleError(error);
});


return () => {
Expand Down

0 comments on commit f0c58df

Please sign in to comment.