Use ws protocol in streaming API base URL (#2606)
This commit is contained in:
parent
629a4d0fca
commit
0cdcf32865
2 changed files with 3 additions and 13 deletions
|
@ -1,17 +1,7 @@
|
|||
import WebSocketClient from 'websocket.js';
|
||||
|
||||
const createWebSocketURL = (url) => {
|
||||
const a = document.createElement('a');
|
||||
|
||||
a.href = url;
|
||||
a.href = a.href;
|
||||
a.protocol = a.protocol.replace('http', 'ws');
|
||||
|
||||
return a.href;
|
||||
};
|
||||
|
||||
export default function getStream(streamingAPIBaseURL, accessToken, stream, { connected, received, disconnected, reconnected }) {
|
||||
const ws = new WebSocketClient(`${createWebSocketURL(streamingAPIBaseURL)}/api/v1/streaming/?access_token=${accessToken}&stream=${stream}`);
|
||||
const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?access_token=${accessToken}&stream=${stream}`);
|
||||
|
||||
ws.onopen = connected;
|
||||
ws.onmessage = e => received(JSON.parse(e.data));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue