Commit a431973b authored by Sadposter's avatar Sadposter

add ping

parent 152c136b
Pipeline #25597 failed with stage
......@@ -84,12 +84,18 @@ export default function getStream(streamingAPIBaseURL, accessToken, stream, { co
params.unshift(`stream=${stream}`);
const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken);
ws.onopen = connected;
ws.onopen = (...args) => {
ws.heartbeat = setInterval(() => ws.send('ping'), 10000);
connected(...args)
};
ws.onmessage = e => {
if (e.data !== '')
received(JSON.parse(e.data));
};
ws.onclose = disconnected;
ws.onclose = (...args) => {
clearInterval(ws.heartbeat);
disconnected(...args);
}
ws.onreconnect = reconnected;
return ws;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment