Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this._socketService.getSocket().onmessage = ((message: Message) => {
- const uiArray = new Uint8Array(message.data);
- this.parseMessage(uiArray);
- });
- parseMessage(uiArray: Uint8Array) {
- let response = null;
- // DOES NOT WORK
- // response = reqRep.Response.deserializeBinary(uiArray) || notif.BackendStatusNotification.deserializeBinary(uiArray);
- // <==== This is where I need to find a good way to deserialize efficiently my objects
- // TEMPORARY
- if (uiArray.byteLength === 56) {
- response = reqRep.Response.deserializeBinary(uiArray)
- } else {
- response = notif.BackendStatusNotification.deserializeBinary(uiArray);
- }
- // Notify different Observables which object has changed based on their type
- switch (response && response.hasSupplement() && response.getSupplement().array[0]) {
- case 'type.googleapis.com/req.BackendStatusResponse':
- this._responseSubject.next(response);
- break;
- case 'type.googleapis.com/notif.BackendStatusNotification':
- this._notificationSubject.next(response);
- break;
- default:
- console.log('DOESN'T WORK');
- }
- }
Add Comment
Please, Sign In to add comment