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