handle empty message (ping) in ws

This commit is contained in:
Morgan Bazalgette 2018-03-31 14:54:56 +02:00 committed by Haelwenn (lanodan) Monnier
parent a6cfa80508
commit 8fc1a6114f
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
2 changed files with 8 additions and 2 deletions

View file

@ -74,7 +74,10 @@ export default function getStream(streamingAPIBaseURL, accessToken, stream, { co
const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken); const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken);
ws.onopen = connected; ws.onopen = connected;
ws.onmessage = e => received(JSON.parse(e.data)); ws.onmessage = e => {
if (e.data !== '')
received(JSON.parse(e.data));
};
ws.onclose = disconnected; ws.onclose = disconnected;
ws.onreconnect = reconnected; ws.onreconnect = reconnected;

View file

@ -74,7 +74,10 @@ export default function getStream(streamingAPIBaseURL, accessToken, stream, { co
const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken); const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken);
ws.onopen = connected; ws.onopen = connected;
ws.onmessage = e => received(JSON.parse(e.data)); ws.onmessage = e => {
if (e.data !== '')
received(JSON.parse(e.data));
};
ws.onclose = disconnected; ws.onclose = disconnected;
ws.onreconnect = reconnected; ws.onreconnect = reconnected;