mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
* WebSocketServer wrapper + socket.io initial support * fix up backpressure * fix up backpressure * fix http address * add socket.io tests * add closing tests * add connection state recovery tests for socket.io * add handshake test * add middeware tests for socket.io * added socket.io socket middleware tests * add more socket.io test comment/skip hang tests * add pending package for tests * add server attachment servers for socket.io * add utility-methods tests for socket.io * rename * rename * add messaging-many socket.io tests * add namespaces tests to socket.io * skip some tests * fmt * add packages to general package.json
14 lines
360 B
JavaScript
14 lines
360 B
JavaScript
const http = require("http").createServer();
|
|
|
|
const io = require("socket.io")(http);
|
|
const port = process.env.PORT || 3000;
|
|
io.on("connection", socket => {
|
|
socket.on("client to server event", msg => {
|
|
io.emit("server to client event", msg);
|
|
});
|
|
});
|
|
|
|
http.listen(port, () => {
|
|
console.log(`Socket.IO server running at http://localhost:${port}/`);
|
|
});
|