Skip to content

Commit

Permalink
fix:Error
Browse files Browse the repository at this point in the history
  • Loading branch information
jinjuseo committed Jun 27, 2024
1 parent e0e89b7 commit 812bea7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/components/Chat/InputBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ const InputBar = ({ roomId }: { roomId: string }) => {
}
} else {
console.log("Chat client is not connected");

const chatClient: StompJs.Client = createChatClient();
chatClient.activate();
chatClient.onConnect = (frame: any) => {
chatClient.unsubscribe("globalChat");
chatClient.subscribe(
chatClient?.deactivate();
chatClient?.unsubscribe("globalChat");
const newChatClient: StompJs.Client = createChatClient();
newChatClient.activate();
newChatClient.onConnect = (frame: any) => {
newChatClient.unsubscribe("globalChat");
newChatClient.subscribe(
`/topic/room/global`,
(message) => {
const receivedMessage = JSON.parse(message.body);
Expand All @@ -47,7 +48,7 @@ const InputBar = ({ roomId }: { roomId: string }) => {
id: "globalChat",
}
);
setChatClient(chatClient);
setChatClient(newChatClient);
};
}
};
Expand Down

0 comments on commit 812bea7

Please sign in to comment.