Skip to content

Instantly share code, notes, and snippets.

@noahjames404
Created May 14, 2025 08:46
Show Gist options
  • Select an option

  • Save noahjames404/f4b30be7cac2667d83479872434b27dd to your computer and use it in GitHub Desktop.

Select an option

Save noahjames404/f4b30be7cac2667d83479872434b27dd to your computer and use it in GitHub Desktop.
socket io simplified server
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