Skip to content

Commit cf3cea7

Browse files
committed
Change ping interval for failure to 5
2 is too short and could be due to latency
1 parent e0bf1a3 commit cf3cea7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

peerprep/components/questionpage/CollabEditor.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import CommsPanel from "./CommsPanel";
1919
// import { diff_match_patch } from "diff-match-patch";
2020
import { callFormatter } from "@/app/api/internal/formatter/helper";
2121
import { Ace } from "ace-builds";
22-
import { connect } from "http2";
2322

2423
const PING_INTERVAL_MILLISECONDS = 5000;
2524
const languages: Language[] = ["javascript", "python", "c_cpp"];
@@ -265,7 +264,7 @@ export default function CollabEditor({
265264
const disconnectCheckInterval = setInterval(() => {
266265
if (
267266
lastPingReceived &&
268-
Date.now() - lastPingReceived > 2 * PING_INTERVAL_MILLISECONDS
267+
Date.now() - lastPingReceived > 5 * PING_INTERVAL_MILLISECONDS
269268
) {
270269
setOtherUserConnected(false);
271270
clearInterval(disconnectCheckInterval);
@@ -276,9 +275,7 @@ export default function CollabEditor({
276275
clearInterval(interval);
277276
clearInterval(disconnectCheckInterval);
278277
};
279-
}, [
280-
notifyRoomOfConnection, PING_INTERVAL_MILLISECONDS, connected, socket
281-
]);
278+
}, [notifyRoomOfConnection, PING_INTERVAL_MILLISECONDS, connected, socket]);
282279

283280
const handleCloseConnection = () => {
284281
const confirmClose = confirm(

0 commit comments

Comments
 (0)