Discard streaming events with empty data
This commit is contained in:
parent
af717ce3b8
commit
9769e0fb77
|
@ -76,9 +76,18 @@ 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.onclose = disconnected;
|
ws.onclose = disconnected;
|
||||||
ws.onreconnect = reconnected;
|
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;
|
return ws;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue