This commit is contained in:
2022-11-14 15:41:11 +01:00
parent 1380575845
commit a7fac21442
17 changed files with 236 additions and 63 deletions

View File

@ -45,8 +45,17 @@ export class WebSocketPayload {
return null;
}
let wsEvent = WebSocketEvent[<keyof typeof WebSocketEvent> rawPayload.event];
let wsEvent = WebSocketEvent[<keyof typeof WebSocketEvent>rawPayload.event];
return new WebSocketPayload(wsEvent, rawPayload.status, rawPayload.data);
}
/**
* Returns the payload as base64 encoded json string
*/
public toString(): string {
let json = JSON.stringify({"event": this._event, status: this._status, data: this._data});
json = (window) ? btoa(json) : Buffer.from(json).toString("base64");
return json;
}
}