Discard streaming events with empty data
This commit is contained in:
parent
af717ce3b8
commit
9769e0fb77
1 changed files with 10 additions and 1 deletions
|
@ -76,9 +76,18 @@ 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.onclose = disconnected;
|
||||
ws.onreconnect = reconnected;
|
||||
|
||||
ws.onmessage = (e) => {
|
||||
if (!e.data) return;
|
||||
try {
|
||||
received(JSON.parse(e.data));
|
||||
} catch(error) {
|
||||
console.error(e);
|
||||
console.error(`Could not parse the above streaming event.\n${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
return ws;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue