# Client-Server Protocol ## 1. Start a connection To start a connection you have to check the versions, generate the sessonID and verify the login. Only if step 1.1 is accomplished is and the sessionID of the client was valid or 1.1 and 1.2 have been accomplished a usable connection is negotiated. ### 1.1 Version check Client: ``` { "version": "versionstring", "sid": "sessionID" } ``` Only sends `sid` if client has an old sessionID. Server: ``` { "version": "versionstring", "accept": bool, "sid": "sessionID" } ``` If `accept` is `true` the connection is valid. Else the connection will be terminated. `sid` must be set if accept is `true` and if the `sid` of the client is invalid. So the server gives a new `sid` if the session is invalid. ### 1.2 Login Client: ``` { "user": "username", "pass": "password", "sid": "sessionID" } ``` Server: ``` { "accept": bool } ``` If `accept` is `true` the connection is valid and the user is logged in. Else the connection will be terminated. The server is not obligated to send `sid` back. ## 2. Sending commands Commands can be sent by the client after a connection has been negotiated (See 1). Commands can be used unrelated to each other. ### 2.1 Status command Client: ``` { "command": "status", "sid": "sessionID" } ``` Server: ``` { "command": "status", "response": "command response" } ``` ### TODO