Added 'invalid message' error.
This commit is contained in:
parent
6abfad391e
commit
dbe3cb97b2
5 changed files with 1988 additions and 1829 deletions
3796
manual/manual.pdf
3796
manual/manual.pdf
File diff suppressed because it is too large
Load diff
|
|
@ -17,13 +17,18 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
= Messages
|
= Messages
|
||||||
|
=== Server
|
||||||
|
```json
|
||||||
|
{"e": 0, "info": "Invalid message"}
|
||||||
|
```
|
||||||
|
|
||||||
== Heartbeat
|
== Heartbeat
|
||||||
=== Server
|
=== Server
|
||||||
- ```json
|
- ```json
|
||||||
{"c": "ping"}
|
{"c": "ping"}
|
||||||
```<ping>
|
```<ping>
|
||||||
- ```json
|
- ```json
|
||||||
{"e": 0, "info": "Pong missed"}
|
{"e": 1, "info": "Pong missed"}
|
||||||
```<pongmissed>
|
```<pongmissed>
|
||||||
|
|
||||||
=== Device
|
=== Device
|
||||||
|
|
@ -55,13 +60,13 @@
|
||||||
{"c": "auth_ok"}
|
{"c": "auth_ok"}
|
||||||
```<auth_ok>
|
```<auth_ok>
|
||||||
- ```json
|
- ```json
|
||||||
{"e": 1, "info": "Invalid packet, wrong ID."}
|
{"e": 2, "info": "Invalid packet, wrong ID."}
|
||||||
```<auth_error_id>
|
```<auth_error_id>
|
||||||
- ```json
|
- ```json
|
||||||
{"e": 2, "info": "Invalid signature."} // the info doesn't matter
|
{"e": 3, "info": "Invalid signature."} // the info doesn't matter
|
||||||
```<auth_error_sig>
|
```<auth_error_sig>
|
||||||
- ```json
|
- ```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>
|
```<auth_error_takeover>
|
||||||
|
|
||||||
=== Device
|
=== Device
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ export class Authentication {
|
||||||
message.d == undefined || !("id" in message.d) ||
|
message.d == undefined || !("id" in message.d) ||
|
||||||
typeof (message.d.id) !== "string" || !(message.d.id in Device.devices)
|
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();
|
this._socket.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +73,7 @@ export class Authentication {
|
||||||
) return;
|
) return;
|
||||||
|
|
||||||
if (this.signature !== parsed.d.signature) {
|
if (this.signature !== parsed.d.signature) {
|
||||||
this._socket.send(buildError(2, "Invalid signature."));
|
this._socket.send(buildError(3, "Invalid signature."));
|
||||||
this._socket.close;
|
this._socket.close;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export class Device {
|
||||||
}
|
}
|
||||||
connect(socket: WebSocket) {
|
connect(socket: WebSocket) {
|
||||||
if (this._socket !== undefined) {
|
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.close();
|
||||||
}
|
}
|
||||||
this._socket = socket;
|
this._socket = socket;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export class WSHeartbeat {
|
||||||
|
|
||||||
this.socket.send(S_PING);
|
this.socket.send(S_PING);
|
||||||
this.pongTimer = setTimeout(() => {
|
this.pongTimer = setTimeout(() => {
|
||||||
this.socket.send(buildError(0, "Pong missed."));
|
this.socket.send(buildError(1, "Pong missed."));
|
||||||
this.socket.close();
|
this.socket.close();
|
||||||
}, HEARTBEAT_TIMEOUT);
|
}, HEARTBEAT_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue