diff --git a/manual/manual.typ b/manual/manual.typ index 4e7959d..72d8282 100644 --- a/manual/manual.typ +++ b/manual/manual.typ @@ -17,13 +17,18 @@ ) = Messages +=== Server +```json +{"e": 0, "info": "Invalid message"} +``` + == Heartbeat === Server - ```json {"c": "ping"} ``` - ```json -{"e": 0, "info": "Pong missed"} +{"e": 1, "info": "Pong missed"} ``` === Device @@ -55,13 +60,13 @@ {"c": "auth_ok"} ``` - ```json -{"e": 1, "info": "Invalid packet, wrong ID."} +{"e": 2, "info": "Invalid packet, wrong ID."} ``` - ```json -{"e": 2, "info": "Invalid signature."} // the info doesn't matter +{"e": 3, "info": "Invalid signature."} // the info doesn't matter ``` - ```json -{"e": 3, "info": "Logged in at other place."} // the info doesn't matter +{"e": 4, "info": "Logged in at other place."} // the info doesn't matter ``` === Device diff --git a/src/auth.ts b/src/auth.ts index ecc6211..5d2ef9c 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -49,7 +49,7 @@ export class Authentication { message.d == undefined || !("id" in message.d) || typeof (message.d.id) !== "string" || !(message.d.id in Device.devices) ) { - this._socket.send(buildError(1, "Invalid packet. Missing ID")); + this._socket.send(buildError(2, "Invalid packet. Missing ID")); this._socket.close(); return; } @@ -73,7 +73,7 @@ export class Authentication { ) return; if (this.signature !== parsed.d.signature) { - this._socket.send(buildError(2, "Invalid signature.")); + this._socket.send(buildError(3, "Invalid signature.")); this._socket.close; return; } diff --git a/src/device.ts b/src/device.ts index 495e274..3f10667 100644 --- a/src/device.ts +++ b/src/device.ts @@ -26,7 +26,7 @@ export class Device { } connect(socket: WebSocket) { if (this._socket !== undefined) { - this._socket.send(buildError(3, "Logged in at other place.")) + this._socket.send(buildError(4, "Logged in at other place.")) this._socket.close(); } this._socket = socket; diff --git a/src/heartbeat.ts b/src/heartbeat.ts index e2bd58a..6ea789b 100644 --- a/src/heartbeat.ts +++ b/src/heartbeat.ts @@ -25,7 +25,7 @@ export class WSHeartbeat { this.socket.send(S_PING); this.pongTimer = setTimeout(() => { - this.socket.send(buildError(0, "Pong missed.")); + this.socket.send(buildError(1, "Pong missed.")); this.socket.close(); }, HEARTBEAT_TIMEOUT); }