diff --git a/doc/protocol.md b/doc/protocol.md new file mode 100644 index 0000000..fa48057 --- /dev/null +++ b/doc/protocol.md @@ -0,0 +1,49 @@ +InstantChat WebSocket Protocol +============================== + +Messages from client to server (commands) +----------------------------------------- + +JSON objects. Key `action` determines type of message. + +### init +Initialize the connection, set nickname and join/create a chat. + +**Parameters:** +* `action` = `"init"` +* `chat_id`: either an existing ID of a chat instance or *[TODO: ?]* empty string to + create a new chat +* `nickname`: user's chosen nickname *[TODO: valid characters?]* + +**Example:** + + { + "action": "init", + "chat_id": "42", + "nickname": "Alice" + } + +### send (?) +Send a message... + +*[TODO]* + + +Messages from server to client (responses/events) +------------------------------------------------- + +JSON objects. Key `type` determines type of message. + +### init +Response to `init` command. Confirms initialization and chat join. + +**Parameters:** +* `type` = `"init"` +* ***[TODO]*** + +**Example:** + + { + "type": "init", + TODO ??? + }