spiegel-keyman/developer/server/src/site/websocket.js
Marc Durdin 2c01b19f69 chore: cleanup
1. Renamed form UfrmNGrokOptions to UfrmServerOptions
2. Renamed kmdev-server to just plain server
3. Tidied up npm versioning to use VERSION_WITH_TAG

This last point should help avoid confusion as now only CI release
builds will ever generate a package.json with a.b.c, a.b.c-alpha or
a.b.c-beta. Local and test builds will always have the corresponding
-test or -local environment appended. This also helps avoid issues if
we accidentally publish an incorrect version.
2021-12-22 06:25:22 +11:00

20 lines
591 B
JavaScript

/* Websocket listening for updated resource notifications */
WebSockHop.disable.mobile = false;
if(WebSockHop.isAvailable()) {
const ws = new WebSockHop((window.location.protocol == 'http:' ? 'ws://' : 'wss://')+window.location.host);
ws.formatter = new WebSockHop.StringFormatter();
ws.formatter.pingMessage = 'ping';
ws.formatter.handlePong = function (message) {
return message == 'pong';
};
ws.on('message', (message) => {
console.log('WebSocket: '+message);
if(message == 'refresh') {
checkKeyboardsAndModels(true);
checkPackages();
}
});
}