MCPcopy
hub / github.com/xiaonanln/goworld

github.com/xiaonanln/goworld @v0.1.6 sqlite

repository ↗ · DeepWiki ↗ · release v0.1.6 ↗
1,638 symbols 4,559 edges 164 files 743 documented · 45%
README

GoWorld

Scalable Distributed Game Server Engine with Hot Reload in Golang

GoDoc Build Status Go Report Card codecov ApacheLicense Join the chat at https://gitter.im/goworldgs/Lobby



中文资料: 游戏服务器介绍 目录结构说明 使用GoWorld轻松实现分布式聊天服务器 欢迎加入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.10.x to install.

go get -d github.com/xiaonanln/goworld
go get -u github.com/golang/dep/cmd/dep
cd $GOPATH/src/github.com/xiaonanln/goworld
dep ensure
go get ./cmd/...

GoWorld uses Dep to manage packages.

For Chinese only: 中国的朋友可能会碰到网络问题,那么您可以通过点击下载vendor.tar.gz,并将其解压到goworld根目录下。

Or using Docker:

# debian-jessie + golang + goworld
docker run -it xiaonanln/goworld
# debian-jessie + golang + goworld + mongodb 3.4 
docker run -it xiaonanln/goworld-dev

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. A running server and client demo can also be found at http://goworldgs.com/chatclient/.

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 Amazon EC2 instance.

Extension points exported contracts — how you extend this code

EntityStorage (Interface)
EntityStorage defines the interface of entity storage backends [5 implementers]
engine/storage/storage_common/storage_common.go
Connection (Interface)
Connection interface for connections to servers [5 implementers]
engine/netutil/Connection.go
KVDBEngine (Interface)
KVDBEngine defines the interface of a KVDB engine implementation [4 implementers]
engine/kvdb/types/kvdb_types.go
IDispatcherClientDelegate (Interface)
IDispatcherClientDelegate defines functions that should be implemented by dispatcher clients [2 implementers]
engine/dispatchercluster/dispatcherclient/DispatcherConnMgr.go
ISpace (Interface)
ISpace is the space delegate interface User custom space class can override these functions for their own game logic [1 …
engine/entity/ISpace.go
AsyncCallback (FuncType)
AsyncCallback is a function which will be called after async job is finished with result and error
engine/async/async.go
PostCallback (FuncType)
PostCallback is the type of functions to be posted
engine/post/post.go
RegisterCallback (FuncType)
(no doc)
engine/srvdis/srvdis.go

Core symbols most depended-on inside this repo

AppendUint16
called by 72
engine/netutil/Packet.go
Add
called by 59
engine/entity/Vector3.go
Error
called by 52
engine/netutil/PacketConnection.go
NewPacket
called by 43
engine/netutil/PacketConnection.go
ReadEntityID
called by 38
engine/netutil/Packet.go
AppendEntityID
called by 31
engine/netutil/Packet.go
SendPacketRelease
called by 30
engine/proto/GoWorldConnection.go
Call
called by 30
engine/entity/Entity.go

Shape

Method 933
Function 530
Struct 125
TypeAlias 23
Interface 14
FuncType 13

Languages

Go100%

Modules by API surface

engine/entity/Entity.go119 symbols
components/dispatcher/DispatcherService.go65 symbols
engine/netutil/Packet.go61 symbols
engine/entity/MapAttr.go50 symbols
engine/proto/GoWorldConnection.go47 symbols
examples/test_client/ClientEntity.go46 symbols
engine/entity/EntityManager.go44 symbols
engine/entity/ListAttr.go43 symbols
engine/config/read_config.go41 symbols
goworld.go35 symbols
cn/goworld_cn.go35 symbols
examples/test_game/Avatar.go28 symbols

Datastores touched

(mongodb)Database · 1 repos
goworldDatabase · 1 repos

For agents

$ claude mcp add goworld \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact