update
Took 25 hours 49 minutes
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import {WebSocketPayload} from "./WebSocketPayload";
|
||||
import {WebSocketEvent} from "./WebSocketEvent";
|
||||
import {iTender} from "./iTender";
|
||||
|
||||
export class WebSocketHandler {
|
||||
private static _ws: WebSocket;
|
||||
@ -14,20 +16,21 @@ export class WebSocketHandler {
|
||||
public static send(payload: WebSocketPayload): Promise<void> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
if( this.ws && this.ws.readyState == 1 )
|
||||
{
|
||||
if (this.ws && this.ws.readyState == 1) {
|
||||
await this.ws.send(payload.toString());
|
||||
resolve();
|
||||
}
|
||||
else
|
||||
{
|
||||
reject("Websocket is not connected!");
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static sendStatus() {
|
||||
return new Promise(resolve => {
|
||||
let payload = new WebSocketPayload(WebSocketEvent.STATUS, false, {status: iTender.status});
|
||||
WebSocketHandler.send(payload).then(resolve);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user