Skip to content

Commit f162037

Browse files
committed
Add pinging to other user during collab
1 parent bf1bbd3 commit f162037

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

collab/main.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (h *Hub) Run() {
141141
}
142142

143143

144-
144+
145145
}
146146
}
147147

@@ -257,6 +257,20 @@ func handleMessages(
257257
log.Println("Client authenticated successfully")
258258
}
259259

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.
263+
264+
userID, _ := msgData["userId"].(string)
265+
request := Message {
266+
RoomID: client.roomID,
267+
UserID: userID,
268+
Content: []byte("ping request"),
269+
}
270+
271+
hub.broadcast <- request
272+
}
273+
260274
if msgData["type"] == "close_session" {
261275
closeMessage := Message{
262276
RoomID: client.roomID,

0 commit comments

Comments
 (0)