Skip to content

WebSocket Server

WebSocket Server

The WebSocket server provides real-time event broadcasting for match updates.

Architecture

The WebSocket server runs on a separate port (default: 3002) and broadcasts events to subscribed clients.

Connection

Connect to the WebSocket server:

const ws = new WebSocket('ws://localhost:3002');

Subscribing to Matches

Subscribe to receive events for a specific match:

{
"type": "subscribe",
"matchId": "AR-2024-0142"
}

Unsubscribing

Unsubscribe from a match:

{
"type": "unsubscribe",
"matchId": "AR-2024-0142"
}

Event Types

Event Message

{
"type": "event",
"data": {
"id": "evt-123",
"matchId": "AR-2024-0142",
"type": "attack",
"agentName": "Red Team Alpha",
"severity": "high",
"timestamp": "2024-12-14T10:01:00Z"
}
}

Match Update

{
"type": "match_update",
"matchId": "AR-2024-0142",
"data": {
"status": "running",
"currentRound": 5,
"score": {
"red": 40,
"blue": 45
}
}
}

Implementation

The WebSocket server uses the ws library and integrates with the Match Runner’s subscription system.

Next Steps