Hacker News new | past | comments | ask | show | jobs | submit login

Yea definitely, I wanted to comment this better but I was just too eager to release it hah.

The run down is this. server.js is a long running script and it only has a few global vars like games and playerQueue. These belong to the application as a whole. They're basically data structures that hold everything that's happening. Which games are being played, which players are waiting, and so on. The main stuff happens with socket.io in the io.sockets.on('connection' ... The paramter 'socket' in this code refers to the connection to a single player so if my server logic says that this player just won the game, I would say socket.emit('won-game') or in my situation I emit a 'gameover' message with some data specifying which username just won.

There's a lot more to it and I plan on getting to commenting the code better but that should point you in the right direction if you want to analyze the code.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: