At first, I just want to learn Golang.I started to think about which is the best way? Because the concurrency mechanisms of Golang is very powerful, I choose online game to verify if I can use Golang to make a efficient game server.For me, this is the first time I make this such hard project. I have to learn Unity, Golang, C# At a time. I am glad that I still have full passion to this project and I never give up.
- golang
- gRPC
- Kubernetes
- Protobuf
- CrossPlatform - Message packet use protobuf which is light, fast, crossplatform.
- Autoscaling - controller is written with go-client ,you can wirte the strategy to autoscale dedicated game server by your own.
- Lightweight - The image of dedicated game server is less than 40MB.
- match players to join other player's room or create own room
- control the amount of gameplay server and load balancing. when the amountof a gameplay server's connections exceed maxium connections it should have, agent will create a new pod run gameplay server.
- After players are matched successfully ,these players will get the gameplay server's ip and token,and player can start to play.
In the branch master, I use ODE to simulate the physics on server.It is the most safe way to keep game fair.However, I found the memory server use is too much for me, Because I don't have money to maintance the server. So I started to design a way to let client validate packet and simulate physics separatly to reduce the heavy load on the server. I just complete the entities can attack each others so far. I will start to design aftewards:
- The validation part preventing form players cheating
- The interface connecting a physics simulator
- Server :
Two Way to run server:
- Run distributed server using Kubernete cluster
- Use Kops to install kubernete on AWS
- Create cluster
- Install Mongodb
- edit setupEnv.sh with your setting and bash setupEnv.sh
go run main.go --type=agent
on your local machine (Must on Where you install Kops)
- Run Standalone Server on local machine
- Install Mongodb
- edit setupEnv.sh( DONT_USE_KUBE = true )with your setting and bash setupEnv.sh
go run main.go --type=standalone
on your local machine
- Run distributed server using Kubernete cluster
- Client :
If you want to make your own game by modifying this project, I am pleasured. You can throught these step to make it work.
- Change the GameFrame message in proto buff.
- Run './update.sh' in 'msg/'
- unzip message.zip under 'Asset/gameServer/proto' in the Unity Project.
- add your handler to "gameServer/game/session/room.go": func (r *Room) Run()
- modify the UpdateFrame fuction to handle packets design by yourself. then,Data Flow to Entity to render the change of entity's properties.
- agent
- session
- room.go
- session.go
- kubernetes.go
- session
- game
- room.go
- session.go
- kubernetes.go
- msg Use Protobuf to define package and RPC service interface
- uuid generate different IDs of objects that can be call with reflection
- user
- UserManager
- User
- storage Use mongoDB to storage user infomation