Files
bun.sh/bench/socketio/server.js
Ciro Spaciari fe74c948cd feat(WebSocketServer) WebSocketServer wrapper + socket.io initial support (#2880)
* 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
2023-05-16 08:48:17 -07:00

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}/`);
});