Skip to main content

Overview

The SolBid WebSocket server broadcasts real-time events to all connected clients. Events are sent as JSON messages and include game creation and bid updates.

Event format

All server events follow this structure:
type
string
The event type identifier
data
object
Event payload containing game or bid information

Event types

new-game

Broadcast when a new game is created and added to the game manager.
{
  "type": "new-game",
  "data": {
    "id": 123,
    "gameId": "game-abc-123",
    "initialBidAmount": 1000,
    "highestBid": 1000,
    "lastBidTime": "2026-03-02T10:30:00.000Z",
    "totalBids": 1,
    "prizePool": 5000,
    "gameEnded": false,
    "createdAt": "2026-03-02T10:00:00.000Z",
    "players": {
      "id": 1,
      "totalBidAmount": 1000,
      "bidCount": 1,
      "bid": {
        "id": 1,
        "amount": 1000,
        "timestamp": "2026-03-02T10:30:00.000Z"
      },
      "user": {
        "id": 42,
        "name": "Alice",
        "imageUrl": "https://example.com/avatar.jpg"
      }
    }
  }
}

Data fields

data.id
number
Unique game identifier
data.gameId
string
Human-readable game ID string
data.initialBidAmount
number
Starting bid amount for the game
data.highestBid
number
Current highest bid amount
data.lastBidTime
string
ISO 8601 timestamp of the most recent bid
data.totalBids
number
Total number of bids placed in this game
data.prizePool
number
Current prize pool amount
data.gameEnded
boolean
Whether the game has ended
data.createdAt
string
ISO 8601 timestamp when the game was created
data.players
object
Player information (currently single player object)
data.players.id
number
Player ID
data.players.totalBidAmount
number
Cumulative total of all bids by this player
data.players.bidCount
number
Total number of bids placed by this player
data.players.bid
object | null
Most recent bid by this player, or null if no bids
data.players.bid.id
number
Unique bid identifier
data.players.bid.amount
number
Bid amount
data.players.bid.timestamp
string
ISO 8601 timestamp when the bid was placed
data.players.user
object
User information
data.players.user.id
number
Unique user identifier
data.players.user.name
string
User display name
data.players.user.imageUrl
string | null
User avatar URL, or null if no image
The new-game event is triggered in gameManager.ts:35 when a game is successfully added to the game manager.

game-update

Broadcast when an existing game is updated with a new bid.
{
  "type": "game-update",
  "data": {
    "id": 123,
    "gameId": "game-abc-123",
    "initialBidAmount": 1000,
    "highestBid": 1500,
    "lastBidTime": "2026-03-02T10:35:00.000Z",
    "totalBids": 2,
    "prizePool": 5500,
    "gameEnded": false,
    "createdAt": "2026-03-02T10:00:00.000Z",
    "players": {
      "id": 1,
      "totalBidAmount": 2500,
      "bidCount": 2,
      "bid": {
        "id": 2,
        "amount": 1500,
        "timestamp": "2026-03-02T10:35:00.000Z"
      },
      "user": {
        "id": 42,
        "name": "Alice",
        "imageUrl": "https://example.com/avatar.jpg"
      }
    }
  }
}

Data fields

The game-update event uses the same data structure as new-game. All fields are identical.
The game-update event is triggered in gameManager.ts:46 when a bid is placed on an existing game.

Client messages

Clients can send messages to trigger game actions. All messages require authentication.

create-game

Create a new game.
{
  "type": "create-game",
  "data": {
    "token": "your-jwt-token",
    // Additional game creation parameters
  }
}
type
string
required
Must be "create-game"
data.token
string
required
Valid JWT token for authentication
Creating a game will trigger a new-game event broadcast to all connected clients.

place-bid

Place a bid on an existing game.
{
  "type": "place-bid",
  "data": {
    "token": "your-jwt-token",
    "id": 123,
    // Additional bid data
  }
}
type
string
required
Must be "place-bid"
data.token
string
required
Valid JWT token for authentication
data.id
number
required
Game ID to place the bid on
Placing a bid will trigger a game-update event broadcast to all connected clients.
If you place a bid on a non-existent game ID, a new game will be created instead of updating an existing one.

Broadcast behavior

All events are broadcast to every connected client simultaneously:
  • Events are only sent to clients with readyState === WebSocket.OPEN
  • Messages are serialized to JSON before sending
  • No acknowledgment or delivery confirmation is provided
The broadcast mechanism is implemented in gameManager.ts:82-89 and ensures all active clients receive updates in real-time.

Error events

See the connection documentation for details on error message format and common error types.

Build docs developers (and LLMs) love