Skip to content

Commit

Permalink
fix: 소켓 에외처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HyeokjinKang committed Nov 6, 2023
1 parent 5f32b51 commit feea7f1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions public/js/globalSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ socket.on("connect", () => {
socket.on("disconnect", (reason) => {
if (reason === "io server disconnect") {
alert(connectionError);
window.location.href = `${api}/auth/logout?redirect=true&shutdowned=true`; // Session error, need to relogin
}
window.location.href = `${api}/auth/logout?redirect=true`; // Session error, need to relogin
} else if (reason === "io client disconnect") return;
console.error("[Socket.IO] Disconnected from server");
iziToast.warning({
title: "Disconnected",
Expand Down Expand Up @@ -50,19 +50,20 @@ socket.on("connect_error", () => {
socket.on("connection:conflict", () => {
socket.disconnect();
alert(connectionConflict);
window.location.href = `${api}/auth/logout?redirect=true&conflicted=true`;
window.location.href = `${api}/auth/logout?redirect=true`;
});

socket.on("connection:unauthorized", () => {
socket.disconnect();
alert(connectionUnauthorized);
window.location.href = `${api}/auth/logout?redirect=true&conflicted=true`;
window.location.href = `${api}/auth/logout?redirect=true`;
});

socket.on("pong", () => {
console.log("[Socket.IO] Pinged");
console.log("[Socket.IO] Pong");
});

const ping = setInterval(() => {
console.log("[Socket.IO] Ping");
socket.emit("ping");
}, 5000);

0 comments on commit feea7f1

Please sign in to comment.