Skip to content

Server Protocol

ayyghost edited this page Jun 22, 2020 · 1 revision

This page describes the new Cryptodog server protocol.

Overview

All communication between a client and the server takes place over a secure WebSocket connection. Messages are serialized as JSON and prefixed with single character byte that identifies the type of the message.

Note that the end-to-end encryption protocol implemented by clients is not discussed here.

Client-to-Server Messages

Join

Join a specified room with a chosen nickname.

j{"room": "room name", "name": "nickname"}

Leave

Leave the room currently occupied by the client, but keep the connection alive. No JSON body required.

l

Group Message

Send a message to the room.

g{"text": "message to send to room"}

Private Message

Send a message to a specific occupant of the room.

p{"to": "recipient of private message", "text": "message to send to recipient"}

Server-to-Client Messages

Join

A user has joined the room.

j{"name": "nickname"}

Leave

A user has left the room.

l{"name": "nickname"}

Group Message

Someone has sent a message to the room.

g{"from": "sender of group message", "text": "message contents"}

Private Message

Someone in the room has sent a private message to the client.

p{"from": "sender of private message", "text": "message contents"}

Roster

Sent to the client upon joining a room to indicate which users are already present.

r{"users": ["nickname1", "nickname2", ...]}

Error

The client did something wrong.

e{"error": "error message"}