cleanup (subfolder removed, npm packages removed, etc.); added y-websocket-server code

This commit is contained in:
User
2026-03-16 02:26:57 +01:00
committed by Jannik Luboeinski
parent 78d5352a48
commit c89c6f95a6
1060 changed files with 610 additions and 101426 deletions

31
backend.js Normal file
View File

@@ -0,0 +1,31 @@
import { WebSocketServer } from 'ws';
import { setupWSConnection } from './utils.js'
// Create a WebSocket server
const WS_PORT = 8080;
const wss = new WebSocketServer({ port: WS_PORT });
console.log('WebSocket server is running on ws://localhost:' + String(WS_PORT));
// Connection event handler
wss.on('connection', setupWSConnection);
/*
wss.on('connection', (ws) => {
console.log('Client connected');
// Message event handler
ws.on('message', (message) => {
let msg_str = String(message);
console.log("Received: " + msg_str);
// If this is a text or state message (no Yjs logic) - echo the message back to the client
if (msg_str.startsWith("TEXT_MESSAGE") | msg_str.startsWith("STATE_MESSAGE")) {
ws.send(msg_str);
}
});
// Close event handler
ws.on('close', () => {
console.log('Client disconnected');
});
});*/