[OA][Infrastructure] - Init WS Server#267
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| } | ||
|
|
||
| ws.on('connection', async (socket, request) => { | ||
| const token = getTokenFromRequest(request); |
There was a problem hiding this comment.
Where does the token get initially added to the connection request? I'm assuming this is something we will set up when configuring the websocket on the client (aka in the react code)
There was a problem hiding this comment.
Yeah the token will be generated using our client and API. As long as the secrets are the same, this will be a successful operation. If not, then the catch will drop the connection.
cherman23
left a comment
There was a problem hiding this comment.
Approved with questions - might require changes based on answers
| }); | ||
|
|
||
| socket.on('error', (err) => { | ||
| console.error(`Socket error for ${socket.userId}:`, err.message); |
There was a problem hiding this comment.
Do we want to send an error message to our main server if it's broken? Lmk if this is even feasible.
There was a problem hiding this comment.
Good point. Let's add this when developing the client side logic.
| }); | ||
|
|
||
| ws.on('error', (err) => { | ||
| console.error('Socket error: ', err); |
[OA][Infrastructure] - Init WS Server
Changes
pingandpongcommands for the heartbeat.userId,isAliveand the_idfromsetInterval. We're going to also most likely want to add some more metadata here eventually such as a "timeout bank" to give each client a set number of seconds of being offline before their OA closes.Notes
ws.on("connection")callback.pongback to the server.Checklist
Please go through all items before requesting reviewers:
Closes
Closes #266