Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e781c6b04a |
@@ -109,7 +109,8 @@ export const API = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
subscribeToEvents(onMessage: (event: any) => void): WebSocket {
|
subscribeToEvents(onMessage: (event: any) => void): WebSocket {
|
||||||
const ws = new WebSocket(`ws://${window.location.host}/api/events`);
|
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
||||||
|
const ws = new WebSocket(`${protocol}://${window.location.host}/api/events`);
|
||||||
ws.onmessage = (event) => {
|
ws.onmessage = (event) => {
|
||||||
onMessage(JSON.parse(event.data));
|
onMessage(JSON.parse(event.data));
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user