Handle errors sent back over the sockt

This commit is contained in:
Dane Everitt 2019-09-28 13:09:47 -07:00
parent b78276d23d
commit 326d346f92
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 32 additions and 13 deletions

View file

@ -51,6 +51,10 @@ export class Websocket extends EventEmitter {
setToken (token: string): this {
this.token = token;
if (this.url) {
this.send('auth', token);
}
return this;
}
@ -60,6 +64,8 @@ export class Websocket extends EventEmitter {
}
close (code?: number, reason?: string) {
this.url = null;
this.token = '';
this.socket && this.socket.close(code, reason);
}