1/* eslint-env browser */
2
3// Setup websocket messages for reloading the page from the command line.
4// This is normally setup on the native client.
5
6const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
7const messageSocket = new WebSocket(`${protocol}://${window.location.host}/message`);
8messageSocket.onmessage = (message) => {
9  const data = JSON.parse(String(message.data));
10  switch (data.method) {
11    case 'sendDevCommand':
12      switch (data.params.name) {
13        case 'reload':
14          window.location.reload();
15          break;
16      }
17      break;
18    case 'reload':
19      window.location.reload();
20      break;
21    case 'devMenu':
22      // no-op
23      break;
24  }
25};
26