Skip to content

Commit e41e20f

Browse files
committed
Temp fix for heartbeat
1 parent febb737 commit e41e20f

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

collab/main.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,20 +256,21 @@ func handleMessages(
256256
client.authenticated = true
257257
log.Println("Client authenticated successfully")
258258
}
259+
// i can comment out this whole block and it would work
259260

260-
if msgData["type"] == "ping" {
261-
//receives ping from client1, need to send a ping to client2
262-
//eventually, if present, client2 will send the ping back, which will be broadcasted back to client1.
261+
// if msgData["type"] == "ping" {
262+
// //receives ping from client1, need to send a ping to client2
263+
// //eventually, if present, client2 will send the ping back, which will be broadcasted back to client1.
263264

264-
userID, _ := msgData["userId"].(string)
265-
request := Message {
266-
RoomID: client.roomID,
267-
UserID: userID,
268-
Content: []byte("ping request"),
269-
}
265+
// userID, _ := msgData["userId"].(string)
266+
// request := Message {
267+
// RoomID: client.roomID,
268+
// UserID: userID,
269+
// Content: []byte("ping request"),
270+
// }
270271

271-
hub.broadcast <- request
272-
}
272+
// hub.broadcast <- request
273+
// }
273274

274275
if msgData["type"] == "close_session" {
275276
closeMessage := Message{

peerprep/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ WORKDIR /frontend
66
COPY package*.json ./
77
RUN npm install --force
88
COPY . .
9-
RUN npm run build
9+
#RUN npm run build
1010
EXPOSE 3000
11-
CMD ["npm", "run", "start"]
11+
CMD ["npm", "run", "dev"]

peerprep/components/questionpage/CollabEditor.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { diff_match_patch } from "diff-match-patch";
2020
import { callFormatter } from "@/app/api/internal/formatter/helper";
2121
import { connect } from "http2";
2222

23-
const PING_INTERVAL_MILLISECONDS = 3000;
23+
const PING_INTERVAL_MILLISECONDS = 15000;
2424
const languages: Language[] = ["javascript", "python", "c_cpp"];
2525

2626
const themes = [
@@ -171,9 +171,10 @@ export default function CollabEditor({
171171
socket.close();
172172
}
173173
router.push("/questions");
174+
} else if (event.data == "ping request") {
175+
// unnecessary with current quick fix
176+
console.log("got event.data == ping request");
174177
} else {
175-
// seem to be getting json error here. logs show messages of "ping" type with both user ids tho
176-
console.log(event.data);
177178
const message: Message = JSON.parse(event.data);
178179

179180
if (message.type === "content_change" && message.userId !== userId) {
@@ -220,6 +221,7 @@ export default function CollabEditor({
220221
const notifyRoomOfConnection = async () => {
221222
// send message over ws
222223
if (socket) {
224+
console.log("PINGING WS FROM " + userId);
223225
const msg: Message = {
224226
type: "ping",
225227
data: "pinging",

0 commit comments

Comments
 (0)