Skip to content

Commit

Permalink
Fix joinpacket/quitpacket broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
Ancocodet committed Dec 19, 2023
1 parent c64a457 commit 39ef1ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const server = Bun.serve<ClientData>({
if (roomManager.joinRoom(webSocket.data.roomId, webSocket.data.uuid)) {
logger.info(`${webSocket.data.uuid} connected to room ${webSocket.data.roomId}`)

webSocket.publish(webSocket.data.roomId, new JoinPacket(webSocket.data.uuid).toString())
server.publish(webSocket.data.roomId, new JoinPacket(webSocket.data.uuid).toString())
webSocket.subscribe(webSocket.data.roomId)
webSocket.send(new WelcomePacket(webSocket.data.uuid, roomManager.getRoom(webSocket.data.roomId)).toString())
} else {
Expand All @@ -63,7 +63,7 @@ const server = Bun.serve<ClientData>({
logger.info(`${webSocket.data.uuid} disconnected from room ${webSocket.data.roomId}`)

webSocket.unsubscribe(webSocket.data.roomId)
webSocket.publish(webSocket.data.roomId, new QuitPacket(webSocket.data.uuid).toString())
server.publish(webSocket.data.roomId, new QuitPacket(webSocket.data.uuid).toString())
}
}
});
Expand Down

0 comments on commit 39ef1ca

Please sign in to comment.