( url: string, command: string, onmessage: WebSocket["onmessage"], onclose: WebSocket["onclose"] )
| 5 | const protocol = ssl ? "wss:" : "ws:"; |
| 6 | |
| 7 | export default function command( |
| 8 | url: string, |
| 9 | command: string, |
| 10 | onmessage: WebSocket["onmessage"], |
| 11 | onclose: WebSocket["onclose"] |
| 12 | ) { |
| 13 | url = removePrefix(url); |
| 14 | url = `${protocol}//${window.location.host}${baseURL}/api/command${url}`; |
| 15 | |
| 16 | const conn = new window.WebSocket(url); |
| 17 | conn.onopen = () => conn.send(command); |
| 18 | conn.onmessage = onmessage; |
| 19 | conn.onclose = onclose; |
| 20 | } |
nothing calls this directly
no test coverage detected