mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
add server
This commit is contained in:
26
server/ws.js
Normal file
26
server/ws.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const { WebSocketServer } = require('ws');
|
||||
|
||||
function setupWebSocket(server) {
|
||||
const wss = new WebSocketServer({ server, path: '/ws' });
|
||||
|
||||
wss.on('connection', (ws) => {
|
||||
console.log('[ws] Client connected');
|
||||
|
||||
ws.on('message', (data) => {
|
||||
// TODO: handle watch/unwatch subscriptions from client
|
||||
const msg = JSON.parse(data);
|
||||
console.log('[ws] Received:', msg);
|
||||
});
|
||||
|
||||
ws.on('close', () => {
|
||||
console.log('[ws] Client disconnected');
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: integrate chokidar file watching and broadcast changes
|
||||
// This will be implemented once the sync strategy is finalized.
|
||||
|
||||
return wss;
|
||||
}
|
||||
|
||||
module.exports = { setupWebSocket };
|
||||
Reference in New Issue
Block a user