📡 Signaling Server - WebSocket API

This WebSocket server facilitates peer-to-peer signaling between a single host and multiple clients.

🔗 Machine-Readable API Spec

JSON API Spec: /api-spec

Returns a WebSocket-specific API specification in JSON format for client generation

🌐 WebSocket Connection

URL: ws://signal.squarespheres.com/ws

📨 Message Format

{
  "type": "string",
  "hostId": "string",
  "clientId": "string",
  "payload": "string"
}

🔁 Message Types

host

Registers a new host.

{
  "type": "host"
}
{
  "type": "host",
  "hostId": "abc123"
}

join-host

Client joins a host by hostId.

{
  "type": "join-host",
  "hostId": "abc123"
}
{
  "type": "join-host",
  "hostId": "abc123",
  "clientId": "xyz456"
}
{
  "type": "client-joined",
  "hostId": "abc123",
  "clientId": "xyz456"
}

msg-to-host

Client sends a message to its host.

{
  "type": "msg-to-host",
  "payload": "message data"
}
{
  "type": "msg-to-host",
  "hostId": "abc123",
  "clientId": "xyz456",
  "payload": "message data"
}

msg-to-client

Host sends a message to a specific client.

{
  "type": "msg-to-client",
  "clientId": "xyz456",
  "payload": "message data"
}
{
  "type": "msg-to-client",
  "hostId": "abc123",
  "clientId": "xyz456",
  "payload": "message data"
}

client-disconnected

Sent to the host when a client disconnects.

{
  "type": "client-disconnected",
  "hostId": "abc123",
  "clientId": "xyz456"
}

host-disconnected

Sent to all connected clients when the host disconnects.

{
  "type": "host-disconnected",
  "hostId": "abc123"
}

❌ Error Messages

If a problem occurs, the server responds with:

📥 ERROR:
{
  "type": "error",
  "message": "description of the error"
}