Added 'invalid message' error.

This commit is contained in:
Jurn Wubben 2025-11-10 10:34:46 +01:00
parent 6abfad391e
commit dbe3cb97b2
5 changed files with 1988 additions and 1829 deletions

File diff suppressed because it is too large Load diff

View file

@ -17,13 +17,18 @@
)
= Messages
=== Server
```json
{"e": 0, "info": "Invalid message"}
```
== Heartbeat
=== Server
- ```json
{"c": "ping"}
```<ping>
- ```json
{"e": 0, "info": "Pong missed"}
{"e": 1, "info": "Pong missed"}
```<pongmissed>
=== Device
@ -55,13 +60,13 @@
{"c": "auth_ok"}
```<auth_ok>
- ```json
{"e": 1, "info": "Invalid packet, wrong ID."}
{"e": 2, "info": "Invalid packet, wrong ID."}
```<auth_error_id>
- ```json
{"e": 2, "info": "Invalid signature."} // the info doesn't matter
{"e": 3, "info": "Invalid signature."} // the info doesn't matter
```<auth_error_sig>
- ```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
```<auth_error_takeover>
=== Device

View file

@ -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;
}

View file

@ -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;

View file

@ -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);
}