forked from nurikk/zigbee2mqtt-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathws.js
More file actions
26 lines (22 loc) · 680 Bytes
/
Copy pathws.js
File metadata and controls
26 lines (22 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const WebSocket = require("ws");
const lineReader = require('line-reader');
const wss = new WebSocket.Server({
port: 8579,
});
wss.on("connection", (ws) => {
lineReader.eachLine('./ws-messages/onConnect.json', (line, last) => {
ws.send(line);
});
ws.addEventListener("message", (message) => {
const msg = JSON.parse(message.data);
switch (msg.topic) {
case "bridge/request/networkmap":
lineReader.eachLine('./ws-messages/networkMapRequest.json', (line, last) => {
ws.send(line);
});
break;
default:
break;
}
});
});