Skip to content

Commit

Permalink
Merge pull request #8 from salt26/seo
Browse files Browse the repository at this point in the history
bug fix
  • Loading branch information
salt26 authored May 22, 2023
2 parents 138320f + 71ee462 commit 21bf111
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions client/src/utils/WebSocketProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const WebsocketProvider = ({ children }) => {

const navigate = useNavigate();
const ws = useRef(null);
const samePersonErr = useRef(false);
// 웹소켓 연결

function createWebSocketConnection(name, setIsLoading) {
Expand All @@ -38,13 +39,14 @@ export const WebsocketProvider = ({ children }) => {
);

socket.onopen = (event) => {
//console.log("Socket open", event);
console.log("Socket open", event);
setIsReady(true);
resolve(socket);
};

socket.onclose = (event) => {
//console.log("onclose!", event);
console.log("onclose!", event);

const currentPath = window.location.href.replace(
window.location.origin,
""
Expand All @@ -56,10 +58,15 @@ export const WebsocketProvider = ({ children }) => {
navigate("/");
return;
}
setIsReady(false);

alert(Language[mode].reconnection_request);
if (samePersonErr) {
samePersonErr.current = false;

setIsReady(false);
return;
}

alert(Language[mode].reconnection_request);
navigate("/");
reject();
};
Expand All @@ -70,6 +77,12 @@ export const WebsocketProvider = ({ children }) => {

if (res?.response === "error") {
alert(res.message);
if (
res.message ===
"The same person has already entered in non-end room."
) {
samePersonErr.current = true;
}
return;
}

Expand Down

0 comments on commit 21bf111

Please sign in to comment.