How nguyentienvn/game_caro works
Caro Realtime is a browser-based multiplayer Caro game using Express-rendered pages and Socket.IO events. Players log in, enter the lobby, create or join a room, and play moves that the server validates and broadcasts; chat, rematches, reconnects, and departures are also supported by the socket controller. Room and player state are held in in-memory models. The game-page client and room model were not excerpted, so their internal event handling and game-rule details are not mapped; documented or indexed links are used only where evidence supports them.
Main entry points: socketController.js Socket Event Controller · server.js HTTP and Socket Server · login.js Login Client · index.js Page Routes
Components 13
Web experience
- HTTP and Socket Server
server.js - Page Routes
routes/index.js - Login, Lobby, Game Views
views - Login Client
public/js/login.js - Lobby Client
public/js/lobby.js - Page Controller
controllers/gameController.js
Realtime gameplay
- Game Client
public/js/game.js - Socket Event Controller
controllers/socketController.js
Runtime state
- Room and Game State
models/RoomModel.js - Player State
models/PlayerModel.js - Room ID Generator
utils/helpers.js
Other components
- Player
- Socket.IO
Connections 16
- Player → Login Client: enters username
public/js/login.js - Login Client → Socket.IO: emits login
public/js/login.js - HTTP and Socket Server → Page Routes: mounts routes
server.js - Page Routes → Page Controller: dispatches pages
routes/index.js - Page Controller → Login, Lobby, Game Views: renders pages
- HTTP and Socket Server → Socket Event Controller: registers handlers
server.js - HTTP and Socket Server → Socket.IO: creates server
server.js - Login Client → Login, Lobby, Game Views: redirects to lobby
public/js/login.js - Lobby Client → Socket.IO: emits room events
public/js/lobby.js - Socket.IO → Socket Event Controller: dispatches events
controllers/socketController.js - Socket Event Controller → Player State: reads and updates
controllers/socketController.js - Socket Event Controller → Room and Game State: reads and updates
controllers/socketController.js - Socket Event Controller → Room ID Generator: generates room IDs
controllers/socketController.js - Socket Event Controller → Socket.IO: broadcasts updates
controllers/socketController.js - Game Client → Socket.IO: exchanges game events
- Player → Lobby Client: browses rooms
public/js/lobby.js