This is a hobby in the spare time to write the project, the purpose of the first edition is to understand the game service side of some design ideas, so basically think of what to write down what, and did not do too detailed design, and premature optimization. In this version, the main function is to complete the following functions:
- Customize a simple communication protocol
- Handle Simple game logic
- Server and client that can run
I. Service-side design
The entire service side is divided into the following sections:
- Basic Communication Module
- Logic Processing Module
- GM Modules
- Server Status Monitoring module
Several high-level abstractions on the server side:
1) Context
The context represents the lifecycle of the entire service and is responsible for starting and stopping all games
2) Game
The game represents different games, each of which customizes its own protocol, and is responsible for creating and destroying the
3) Guest
The hostel is responsible for handling the game logic and controlling the game's progress
4) Charactor
Each charactor represents a player and stores some basic information about the player.
5) Dispatcher
Dispatcher responsible for the distribution of messages
6) Processor
Processor is the final processing terminal of the message
Throughout the server, Netty is responsible for establishing connections, receiving and sending messages, and Netty receiving messages, distributing messages from Netty threads (Netty-initiated threads) to the user thread (processing game logic), where Jactor2 is used to complete communication between threads
Two. Client Design
The client is relatively simple, reference here, the UI based on the Raphael Library, there are only a few basic functions,
The following will take out some of the basic components, and finally refine into a small engine
Project Address: https://github.com/occume/D3000