How teddyxiong53/guess_num works
Project type and purpose
• This is a multiplayer “guess the number” game server built on the Skynet lightweight game‐server framework.
• All code is in Lua and lives under the app/ directory. Skynet launches each Lua file as a separate “service.”
• Users connect via TCP (port 8888) and issue text commands (login, ready, guess, etc.).
File structure
• Top level
• config/ – Skynet configuration files (defines services, thread pools, logging, network bindings).
• app/ – Lua services that Skynet will launch.
– main.lua – bootstrap service that starts your other services.
– redis.lua – a Skynet service that wraps Redis calls (caching, persistence).
– hall.lua – matchmaking/hall logic: queues players, assigns them to rooms.
– agent.lua – per‐connection service: parses client commands, forwards them to hall/room.
– room.lua – game‐room service: holds game state, enforces guess logic and turn order.
README for insights
• Skynet startup sequence (bootstrap → launcher → harbor → datacenter → service_mgr → main → …).
• Example logs show agents being launched dynamically for each new TCP client, plus one persistent room service.
• Flow: client connects → agent spawns → login → ready → hall assigns a “room” → room governs the game → room signals end → agent closes.
Detailed breakdown of components
• Skynet Core: thread pool, message queue
• bootstrap.lua & launcher (start sequence)
• datacenterd & service_mgr (service registry)
• main.lua (your custom init)
• redis.lua (client wrapper) → Redis Server
• hall.lua (matchmaking logic)
• agent.lua (per‐client handler)
• room.lua (game instance)
• TCP clients
Final advice
• Dynamic interactions (agent spawn, room spawn).