init commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
|
||||
import express from 'express';
|
||||
import http from 'http';
|
||||
import { Server } from 'socket.io';
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
const io = new Server(server, {
|
||||
cors: {
|
||||
origin: "http://localhost:5173", // allow Vite frontend
|
||||
methods: ["GET", "POST"]
|
||||
}
|
||||
});
|
||||
|
||||
// Socket.IO events
|
||||
io.on("connection", (socket) => {
|
||||
console.log("Client connected:", socket.id);
|
||||
|
||||
socket.on("paramUpdate", (data) => {
|
||||
socket.broadcast.emit("paramUpdate", data);
|
||||
});
|
||||
|
||||
socket.on("disconnect", () => {
|
||||
console.log("Client disconnected:", socket.id);
|
||||
});
|
||||
});
|
||||
|
||||
app.use(express.static('frontend/dist'));
|
||||
server.listen(3000, () => console.log('Server running on http://localhost'));
|
||||
Reference in New Issue
Block a user