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 805385ff53
commit 502b354a1a
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
2 changed files with 8 additions and 2 deletions

View file

@ -85,7 +85,10 @@ export default function getStream(streamingAPIBaseURL, accessToken, stream, { co
const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken);
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.onreconnect = reconnected;

View file

@ -85,7 +85,10 @@ export default function getStream(streamingAPIBaseURL, accessToken, stream, { co
const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken);
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.onreconnect = reconnected;