summaryrefslogtreecommitdiff
path: root/frontend/src/utils
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@amadeus.com>2017-07-18 19:01:06 +0200
committerJoffrey Bion <joffrey.bion@amadeus.com>2017-07-18 19:01:06 +0200
commit4a1827b5619da5f5e877263d06f108cae558f1cb (patch)
tree1a360ef0a2fc1945917b006a676127b5690084e1 /frontend/src/utils
parentUpdate gradle wrapper to 4.0.1 (diff)
downloadseven-wonders-4a1827b5619da5f5e877263d06f108cae558f1cb.tar.gz
seven-wonders-4a1827b5619da5f5e877263d06f108cae558f1cb.tar.bz2
seven-wonders-4a1827b5619da5f5e877263d06f108cae558f1cb.zip
Fix handler for empty websocket messages
Diffstat (limited to 'frontend/src/utils')
-rw-r--r--frontend/src/utils/websocket.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/frontend/src/utils/websocket.js b/frontend/src/utils/websocket.js
index b01531cf..6acd0806 100644
--- a/frontend/src/utils/websocket.js
+++ b/frontend/src/utils/websocket.js
@@ -41,7 +41,9 @@ export const createWsConnection = (headers: Object = {}): Promise<SocketObjectTy
export const createSubscriptionChannel = (socket: SocketType, path: string) => {
return eventChannel((emitter: (data: any) => void) => {
const socketSubscription: SocketSubscriptionType = socket.subscribe(path, (event: SocketEventType) => {
- emitter(JSON.parse(event.body));
+ // not all events have a body
+ const value = event.body && JSON.parse(event.body);
+ emitter(value);
});
return () => socketSubscription.unsubscribe();
});
bgstack15