Overview
The SolBid WebSocket server provides real-time updates for game events and bids. The server is built with thews library and requires JWT authentication for all connections.
Connection URL
Connect to the WebSocket server at:PORT environment variable.
Authentication flow
All WebSocket connections must authenticate immediately after connecting by sending a JWT token.Initial authentication message
After establishing the WebSocket connection, send an authentication message:Valid JWT token signed with
NEXT_PUBLIC_SECRETAuthentication responses
Success: No response is sent on successful authentication. You can proceed to send messages. Failure: An error message is sent before the connection closes:Connection lifecycle
1. Establish connection
2. Handle messages
After authentication, you’ll receive real-time game events:3. Send messages
After successful authentication, you can send game-related messages:All client messages must include the JWT token in the
data.token field for authentication.4. Handle disconnection
Error handling
The server sends error messages in the following format:Always
"error" for error messagesCommon errors
Token not found- No token was provided in the messageUnauthorized- JWT token verification failedUnknown message type: {type}- Invalid message type sent to serverFailed to process message- JSON parsing or other processing error
Connection management
The server maintains a singletonGameManager instance that tracks all connected clients. When you connect:
- Your WebSocket connection is added to the clients set
- You receive all future game broadcasts
- On disconnect, you’re automatically removed from the client list
The server logs connection counts to the console:
New client connected. Total clients: {count}