Created
May 14, 2025 08:46
-
-
Save noahjames404/f4b30be7cac2667d83479872434b27dd to your computer and use it in GitHub Desktop.
socket io simplified server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Server } = require("socket.io"); | |
| const io = new Server({ /* options */ }); | |
| io.on("connection", (socket) => { | |
| console.log(`user connected:`,socket.id); | |
| socket.on("msg",(arg1) => { | |
| console.log(arg1); | |
| socket.broadcast.emit("response",arg1); | |
| }); | |
| }); | |
| io.on("hello", (arg1) => { | |
| console.log(arg1); // prints "world" | |
| }); | |
| io.listen(3000); | |
| console.log("started"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment