// WebSocket echo for testing deployshed's laptop tunnel: echoes each message // and pushes a tick every 5 s so a long-lived connection is visible. const http = require('http'); const { WebSocketServer } = require('ws'); const server = http.createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('ws-echo: connect with a WebSocket to this address\n'); }); const wss = new WebSocketServer({ server }); wss.on('connection', (ws) => { ws.send('hello'); ws.on('message', (m) => ws.send('echo:' + m)); const t = setInterval(() => ws.send('tick:' + Date.now()), 5000); ws.on('close', () => clearInterval(t)); }); server.listen(process.env.PORT || 8080);