sync commit

This commit is contained in:
2026-01-30 17:49:13 -06:00
parent 9d7234f2f0
commit 9eb51b7e9f
3 changed files with 110 additions and 0 deletions

18
server.js Normal file
View File

@@ -0,0 +1,18 @@
import {WebSocketServer} from 'ws'
const wss = new WebSocketServer({port: 8081})
// conmnection event
wss.on('connection', (s, r)=>{
const ip = r.socket.remoteAddress
s.on('message', (rawData)=>{
const message = rawData.toString()
console.log({rawData})
wss.clients.forEach((c)=>{
if(c.readyState === 1) c.send(`Server Broadcast: ${message}`)
})
})
})