Implement websocket notifications for center status, mode and few other changes

This commit is contained in:
David Majdandžić
2023-03-25 17:55:56 +01:00
parent b8e9642507
commit 9773cce836
2 changed files with 143 additions and 23 deletions

View File

@@ -3,10 +3,18 @@ const WebSocket = require('ws');
const WS_SERVER_PORT = process.env.WS_SERVER_PORT || 8191;
const ws = new WebSocket(`ws://localhost:${WS_SERVER_PORT}`);
const ws2 = new WebSocket(`ws://localhost:${WS_SERVER_PORT}`);
ws.on('open', () => {
console.log('WebSocket connection established');
ws.send(0);
ws.send("client:0");
});
ws.on('message', (data) => {
console.log(String(data));
});
ws2.on('open', () => {
console.log('WebSocket connection established');
ws.send("center:0");
});
ws2.on('message', (data) => {
console.log(String(data));
});