1. 程式人生 > >xiaonanln/goworld: Scalable Distributed Game Server Engine with Hot Swapping in Golang

xiaonanln/goworld: 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 Join the chat at https://gitter.im/goworldgs/Lobby

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根目錄下。

# 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 Huawei Cloud instance.

相關推薦

xiaonanln/goworld: Scalable Distributed Game Server Engine with Hot Swapping in Golang

GoWorld Scalable Distributed Game Server Engine with Hot Reload in Golang Features Spaces & Entities: manage multiple spaces and entities w

Sending big file with minimal memory in Golang

Sending big file with minimal memory in GolangA hungry gopherMost common way of uploading file(s) by http is splitting them in multiple parts (multipart/fo

Mastering the game of Go with deep neural networks and tree search

深度 策略 參數初始化 技術 以及 -1 簡單 cpu 網絡 Silver, David, et al. "Mastering the game of Go with deep neural networks and tree search." Nature 529.758

'IOKING' TCP Transmission Server Engine ('雲猴'©TCP通訊server引擎)(預告版)

隊列 ipv6 spa href 什麽 監聽 內存 關鍵詞 由於 關鍵詞: IOKING IOCP TCP Transmission Server Engine Lock Free Interlocked 雲猴完畢portTCP通訊server引擎 無鎖 原子鎖(函數

Failed to load resource: the server responded with a status of 404 (Not Found)

PE nbsp ava col AI div short rtc not Failed to load resource: the server responded with a status of 404 (Not Found) 報錯情況:圖標加載失敗 原因分析:路徑錯誤

SQL ServerWITH (NOLOCK)

共享鎖 這樣的 time baidu view 舉例 其它 ima inf 概念介紹開發人員喜歡在SQL腳本中使用WITH(NOLOCK), WITH(NOLOCK)其實是表提示(table_hint)中的一種。它等同於 READUNCOMMITTED 。 具體的功能作用如

SQL Server 利用WITH AS遞迴獲取層級關係資料

WITH AS短語,也叫做子查詢部分(subquery factoring),在SQL Server 2005中提供了一種解決方案,這就是公用表表達式(CTE),使用CTE,可以使SQL語句的可維護性,同時,CTE要比表變數的效率高得多。     下面是CTE的語法:

Mastering the game of Go with deep neural networks and tree search譯文

用深度神經網路和樹搜尋征服圍棋 作者:David Silver 1 , Aja Huang 1 , Chris J. Maddison 1 , Arthur Guez 1 , Laurent Sifre 1 , George van den Driessche

小程式執行報錯:“Failed to load local image resource xxx.png the server responded with?

錯誤原因: 由於這是因為初始化的時候,變數還沒渲染進去導致的。 解決方法: 在src前面加個: wx:if<image wx:if='{{customerLevel.value}}' class

前端頁面the server responded with a status of 500 ()的非典型性BUG

非典型的,在使用ssm框架操作資料庫的時候報錯500和NullPointerException 前端頁面報錯:Failed to load resource: the server responded with a status of 500 () 後臺控制器

ajax使用時的錯誤the server responded with a status of 404 (Not Found)

使用ajax跳轉方法時,頁面ctrl+shift+i除錯報告了一個404錯誤,說找不到方法。頁面位址列直接指向方法的地址跳轉也是404。目標方法是新增的,於是使用複製黏貼,確定各處方法名稱一致之後,重啟server。  除錯時再次報錯: jquery.min.js Fail

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

【原因】 因為這個表和另一個表是有一對多關係的,當序列化表1的時候,會找到和另一個表2關聯的欄位,就會到另一個表2中序列化,然後另一個表2中也有一個欄位和表1相關聯.這樣.序列化就會發生這種錯誤! 【解決方案】 /注:這裡值得注意的是,當有外來鍵向關聯時,必須要指定序列化元素,如果沒有外來鍵相關聯,直接序

NVelocity View Engine with Asp.net Mvc

因為要將CHSNS#轉到Asp.net MVC平臺上來,所以就有了在Asp.net Mvc平臺下NVelocity的引擎問題 MvcContrib雖然也有NVelocity的引擎,不過整體錯誤不少.還必需要Castle.Windsor來動態引入ViewEngine 怎麼看都不爽,於是自寫了一個NVel

Children's violent video game play associated with increased physical aggressive behavior

Although most researchers on the subject agree that playing violent video games appears to increase physical aggression, a vocal minority continues to dis

How Spektacom is Powering the Game of Cricket with Microsoft AI | Machine Learning Blog

A special guest post by cricket legend and founder of Spektacom Technologies, Anil Kumble. This post was co-authored by Tara Shankar Jana, Senior Techn

js註釋後Failed to load resource: the server responded with a status of 404 (Not Found)

畫面輸入框對應內容長度限制的js內容進行註釋(在controller.js中進行註釋)後,畫面出現Failed to load resource: the server responded with a status of 404 (Not Found) 利用: /* $("#upClass

Failed to load resource: the server responded with a status of 403

Failed to load resource: the server responded with a status of 403 () personList.html:1 Failed to load http://192.168.0.103/person/getList: Resp

微信小程式 the server responded with a status of 404 錯誤解決方法

微信小程式開發,剛剛接觸這個小程式,遇到了題目中的問題,也就是在WXSS中無法使用background-image這個功能 後來經過各種查終於找到了解決方法。 首先官方給的說明是:background-image:可以使用網路圖片,或者 base64,或者使用<im

AWS Marketplace: Microsoft Windows Server 2016 with SQL Server 2017 Enterprise

AWS Marketplace is hiring! Amazon Web Services (AWS) is a dynamic, growing business unit within Am

AWS Marketplace: Microsoft Windows Server 2016 with SQL Server 2017 Express

AWS Marketplace is hiring! Amazon Web Services (AWS) is a dynamic, growing business unit within Am