📡 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.
📥 RESPONSE:
{
"type": "host",
"hostId": "abc123"
}
join-host
Client joins a host by hostId.
📤 PAYLOAD:
{
"type": "join-host",
"hostId": "abc123"
}
📥 RESPONSE TO CLIENT:
{
"type": "join-host",
"hostId": "abc123",
"clientId": "xyz456"
}
📥 NOTIFICATION TO HOST:
{
"type": "client-joined",
"hostId": "abc123",
"clientId": "xyz456"
}
msg-to-host
Client sends a message to its host.
📤 PAYLOAD:
{
"type": "msg-to-host",
"payload": "message data"
}
📥 FORWARDED TO HOST:
{
"type": "msg-to-host",
"hostId": "abc123",
"clientId": "xyz456",
"payload": "message data"
}
msg-to-client
Host sends a message to a specific client.
📤 PAYLOAD:
{
"type": "msg-to-client",
"clientId": "xyz456",
"payload": "message data"
}
📥 FORWARDED TO CLIENT:
{
"type": "msg-to-client",
"hostId": "abc123",
"clientId": "xyz456",
"payload": "message data"
}
client-disconnected
Sent to the host when a client disconnects.
📥 NOTIFICATION:
{
"type": "client-disconnected",
"hostId": "abc123",
"clientId": "xyz456"
}
host-disconnected
Sent to all connected clients when the host disconnects.
📥 NOTIFICATION:
{
"type": "host-disconnected",
"hostId": "abc123"
}
❌ Error Messages
If a problem occurs, the server responds with:
📥 ERROR:
{
"type": "error",
"message": "description of the error"
}