Implement websocket server

This commit is contained in:
David Majdandžić
2023-03-24 16:16:13 +01:00
parent f535315b6f
commit 5ac4a6275b
3 changed files with 83 additions and 2 deletions

12
websocketTest.js Normal file
View File

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