Skip to main content

WebSocket Connection

Connection URL

WebSocket connection is created in the following format:

ws://{API_URL}/ws?room_id={room_id}&name={playerName}&currency={currency}&launch_url_token={token}&token={inGameToken}

Query Parameters:

  • room_id (string, required): Room ID
  • name (string, required): Player name
  • currency (string, required): Currency (e.g., "USD")
  • launch_url_token (string, required): Token from URL
  • token (string, required): In-game authentication token

Example:

ws://{API_URL}/ws?room_id=room-123&name=Player1&currency=USD&launch_url_token=abc123&token=xyz789

Connection States

WebSocket connection emits the following events:

  • SOCKET_CONNECTING: Connecting
  • SOCKET_CONNECTED: Connection successful
  • SOCKET_RECONNECT: Reconnected
  • SOCKET_MESSAGE: Message received
  • SOCKET_ERROR: Error occurred
  • SOCKET_CLOSE: Connection closed
  • SOCKET_DISCONNECT: Connection disconnected

Auto-Reconnect

WebSocket has automatic reconnection capability:

  • Automatically attempts to reconnect when connection is closed
  • Reconnect delay: 1000ms (default)
  • Controlled by autoReconnect flag