• Stars
    star
    2,565
  • Rank 17,878 (Top 0.4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Scalable Distributed Game Server Engine with Hot Swapping in Golang

GoWorld

Scalable Distributed Game Server Engine with Hot Reload in Golang

GoDoc Build Status Go Report Card codecov ApacheLicense


中文资料

中文文档
游戏服务器介绍
目录结构说明
使用GoWorld轻松实现分布式聊天服务器

游戏服务端开源引擎GoWorld教程

1.安装和运行
2.Unity示例双端联调
3.手把手写一个聊天室
4.多个频道的聊天室
5.登录注册和存储
6.移动同步和AOI
7.源码解析之启动流程和热更新
8.码解析之gate
9.源码解析之dispatcher
10.源码解析之entity


欢迎加入Go服务端开发交流群:662182346


Features

  • Spaces & Entities: manage multiple spaces and entities with AOI support
  • Distributed: increase server capacity by using more machines
  • Hot-Swappable: update game logic by restarting server process
  • Multiple Communication Protocols: supports TCP, KCP and WebSocket
  • Traffic Compression & Encryption: traffic between clients and servers can be compressed and encrypted

Architecture

GoWorld Architecture

Introduction

GoWorld server adopts an entity framework, in which entities represent all players, monsters, NPCs. Entities in the same space can visit each other directly by calling methods or access attributes. Entities in different spaces can call each over using RPC.

A GoWorld server consists of one dispatcher, one or more games and one or more gates. The gates are responsible for handling client connections and receive/send packets from/to clients. The games manages all entities and runs all game logic. The dispatcher is responsible for redirecting packets among games and between games and gates.

The game processes are hot-swappable. We can swap a game by sending SIGHUP to the process and restart the process with -restore parameter to bring game back to work but with the latest executable image. This feature enables updating server-side logic or fixing server bugs transparently without significant interference of online players.

Installing GoWorld

GoWorld requries Go 1.11+ to install.

go install github.com/xiaonanln/goworld/cmd/...

Manage GoWorld Servers

Use command goworld to build, start, stop and reload game servers.

Build Example Chatroom Server:

$ goworld build examples/chatroom_demo

Start Example Chatroom Server: (dispatcher -> game -> gate)

$ goworld start examples/chatroom_demo

Stop Game Server (gate -> game -> dispatcher):

$ goworld stop examples/chatroom_demo

Reload Game Servers:

$ goworld reload examples/chatroom_demo

Reload will reboot game processes with the current executable while preserving all game server states. However, it does not work on Windows.

List Server Processes:

$ goworld status examples/chatroom_demo
> 1 dispatcher running, 1/1 gates running, 1/1 games (examples/chatroom_demo) running
> 	2763      dispatcher      /home/ubuntu/go/src/github.com/xiaonanln/goworld/components/dispatcher/dispatcher -dispid 1
> 	2770      chatroom_demo   /home/ubuntu/go/src/github.com/xiaonanln/goworld/examples/chatroom_demo/chatroom_demo -gid 1
> 	2779      gate            /home/ubuntu/go/src/github.com/xiaonanln/goworld/components/gate/gate -gid 1

Demos

Chatroom Demo

The chatroom demo is a simple implementation of chatroom server and client. It illustrates how GoWorld can also be used for games which don't divide players by spaces.

The chatroom demo provides following features:

  • register & login
  • send chat message
  • switch chatrooms

Build Server:

goworld build examples/chatroom_demo

Run Server:

goworld start examples/chatroom_demo

Chatroom Demo Client:

Chatroom demo client implements the client-server protocol in Javascript.
The client for chatroom demo is hosted at github.com/xiaonanln/goworld-chatroom-demo-client. The project was created and built in Cocos Creater 1.5.

Unity Demo

Unity Demo is a simple multiple player monster shooting game to show how spaces and entities of GoWorld can be used to create multiple player online games.

  • register & login
  • move players in space
  • summon monsters
  • player shoot monsters
  • monsters attack players

Developing features:

  • Hit effects
  • Players migrate among multiple spaces
  • Server side map navigation

Build Server:

goworld build examples/unity_demo

Run Server:

goworld start examples/unity_demo

Unity Demo Client:

Unity demo client implements the client-server protocol in C#. The client for unity demo is hosted at https://github.com/xiaonanln/goworld-unity-demo. The project was created and built in Unity 2017.1.

You can try the demo by downloading GoWorldUnityDemo.zip. The demo connects to a goworld server on Huawei Cloud instance.

More Repositories

1

goworld-unity-demo

Unity3d demo using GoWorld as game server
C#
30
star
2

go-aoi

Golang Area-Of-Interest (AOI) Implementations
Go
21
star
3

go-xnsyncutil

My Go sync utils
Go
17
star
4

keylock

Golang utility class KeyLock: lock by string key, so as to avoid giant lock
Go
15
star
5

goworld-chatroom-demo-client

GoWorld Chatroom Demo Client
JavaScript
12
star
6

goTimer

Timer framework in Golang (heap)
Go
12
star
7

go-lockfree-queue

Lock free queue in golang
Go
11
star
8

distributed-system-papers-must-read

Collect must-read papers on distributed systems
11
star
9

study-algorithm-design

Write code to study Algorithm Design
Python
10
star
10

pktconn

Packet connection over net.Conn (Golang)
Go
5
star
11

go-skiplist

Skip List implementation in Golang
Go
4
star
12

go-trie-tst

Trie and Ternary Search Tree implemented in Golang
Go
2
star
13

learn-raft

learn raft by implementing it in Golang - I am still learning ...
Go
2
star
14

mflru

lru cache with memory footprint limit
Go
2
star
15

pyastop

Python AST Optimizer based on Global Analysis and Comments - developing
Python
2
star
16

go-set

implement different kind of sets for go since go has no generic
Go
2
star
17

lockd

Distributed Locking Service -- under development
Go
2
star
18

go-consistent

Go consistent hashing library
Go
2
star
19

GoWorldUnity3D

Unity3D Game Client Library for GoWorld Server
C#
2
star
20

go-lockfree-pool

Pool like sync.Pool but uses lock-free queue for better performance
Go
2
star
21

entities

Distributed Entities with efficient RPC
Go
1
star
22

wheeltimer

wheel timer that works just like time.After, time.Tick, time.NewTicker(implementing)
Go
1
star
23

pyuv-test

test pyuv performance
Python
1
star
24

golrucache

A Golang LRU cache implementation
Go
1
star
25

goSyncQueue

Synchronious queues with infinite buffer size in Golang
Go
1
star
26

pyEasyGo

Load Go shared library and call Go functions easily in Python
Python
1
star
27

taomp-go

『THE ART of MULTIPROCESSOR PROGRAMMING』 in Golang
Go
1
star
28

LNGS

Simple high-performance mobile game server engine writtin in Go.
Go
1
star
29

typeconv

Type conversion module for golang
Go
1
star
30

opengles2-book-sample

opengles2-book-sample
C
1
star
31

PyHAAS

Highly Available Auto-Scaling Services in Python (experimenting ideas ...)
Python
1
star