Skip to content

Commit

Permalink
Add UUID packet upon WebSocket connection
Browse files Browse the repository at this point in the history
Added a command to send a UUID packet to each newly connected client in index.ts file. By doing this, a client can instantly receive their own UUID upon connection, which can be useful in managing individual client data or behaviors.
  • Loading branch information
Ancocodet committed Dec 1, 2023
1 parent 1278e25 commit a6e1cd4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const server = Bun.serve<ClientData>({
logger.info(`${webSocket.data.uuid} connected to room ${webSocket.data.roomId}`)
webSocket.subscribe(webSocket.data.roomId)

webSocket.send(new SimplePacket("UUID", webSocket.data.uuid).toString())
webSocket.send(new SimplePacket("INFO", roomManager.getRoom(webSocket.data.roomId)).toString())
webSocket.publish(webSocket.data.roomId, new SimplePacket('JOIN', webSocket.data.uuid).toString())
} else {
Expand Down

0 comments on commit a6e1cd4

Please sign in to comment.