(path: string, token: string)
| 2 | import { WS_URL_PREFIX } from 'config/env' |
| 3 | |
| 4 | export const initWS: InitWS = (path: string, token: string): WebSocket => { |
| 5 | const url = new URL(WS_URL_PREFIX + path, window.location.href); |
| 6 | url.protocol = url.protocol.replace('http', 'ws'); |
| 7 | const wsAddr = url.href + '?token=' + token; |
| 8 | |
| 9 | return new WebSocket(wsAddr) |
| 10 | } |