Giter Site home page Giter Site logo

goworld's Introduction

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.

goworld's People

Contributors

github-yxb avatar gitter-badger avatar luopeiyu avatar mdhender avatar p3ddd avatar simonlingoogle avatar sonarbeserk avatar xiaonanln avatar zengjiwen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goworld's Issues

属性同步代码实现是哪个?

属性同步

GoWorld为Entity提供了属性机制。属性分为服务端属性、客户端属性和全局属性。服务端属性只有在服务端可以访问,客户端属性可以在客户端和服务端同时访问。每次服务端对其进行修改的时候,属性的变化会立刻被同步到客户端,从而保持客户端数据的实时更新。全局属性是对所有Entity都可见的数据,包括其他玩家。全局属性在发生变化的时候会被广播到AOI范围内的所有玩家,从而使得玩家可以实时获取AOI范围内其他Entity的属性变化。

想学习一下实现

go get dependency error

$ go get github.com/xiaonanln/goworld
# cd .; git clone https://gopkg.in/eapache/queue.v1 
fatal: unable to access 'https://gopkg.in/eapache/queue.v1/': Unknown SSL protocol error in connection to gopkg.in:-9838
package gopkg.in/eapache/queue.v1: exit status 128
fatal: unable to access 'https://gopkg.in/ini.v1/': Unknown SSL protocol error in connection to gopkg.in:-9838
package gopkg.in/ini.v1: exit status 128
# cd .; git clone https://gopkg.in/vmihailenco/msgpack.v2 
fatal: unable to access 'https://gopkg.in/vmihailenco/msgpack.v2/': Unknown SSL protocol error in connection to gopkg.in:-9838
package gopkg.in/vmihailenco/msgpack.v2: exit status 128
# cd .; git clone https://gopkg.in/natefinch/lumberjack.v2 
fatal: unable to access 'https://gopkg.in/natefinch/lumberjack.v2/': Unknown SSL protocol error in connection to gopkg.in:-9838
package gopkg.in/natefinch/lumberjack.v2: exit status 128

[not an issue] performance measurements

Hello,

First of all, very nice project, keep it up!
And second, I have a few questions:

  1. Did you conduct any performance measurements for goworld server?
  2. How many simultaneous client connections it can handle (with one, and multiple gates)?
  3. Does goworld support a 60HZ or 30HZ sync modes, and how many entities it can handle with such rate, (probably disabled encryption/compression) ?
  4. What are the theoretical limitations for the entity amount ?

And more general question, do you have some sort of text description about your network culling algorithm? As far as I understood you call it Area of Interest.

Thank you! 👍

Provide general MongoDB access | 提供对MongoDB的支持

虽然goworld使用了大量goroutine,但是每个Entity的RPC函数的处理依然是异步的,Entity的rpc函数里不能直接调用堵塞的mongodb api。所以goworld需要为MongoDB的访问提供一种异步的请求+应答的访问接口

v0.1

Version v0.1

  • Basic functionalities: entity, attributes,
  • TCP, KCP, WEBSOCKET
  • Reload
  • ext: db/gwmongo, pubsub, msgbox
  • strip useless code

add ListAttr

Entity attributes currently support MapAttr, add ListAttr

建议考虑支持 client 端的 request-response 模式

现在 goworld 在 client 端调用 rpc 时候不能支持 request/response 模式,比如:

const player = client.getPlayer()
player.callServer("hitBoss", spell, function(result) {
...
})

这种请求应答模式是否考虑支持?这种编程模式在有些场景下开发感觉更简洁。

[unity-demo] Player position not getting set on the server

I tried running the unity demo today and it works fine until it doesn't: The player positions does not seem to sync with the server quite right. The packet arrives, but at the wrong entity.

Somehow during the lifecycle the entity.syncingFromClient property is returning false as the player entity changes (even though the ID stays the same). Furthermore, the player entity seems to get added twice, which probably means we load the same player twice, but don't initialize them correctly - and thus overwrite the existing copy since it's a map.

优化Space.move

开销似乎有点大

主要开销都在2个Interested函数和一个Join函数,里面所涉及到的map操作:mapassign

热重启的性能如何?

有没有测试过一个进程的entity数据量和热重启花费时间的关系,顿卡时间有多长

Write a new goworld manager in golang, get ride of goworld.py

So that all sources are written in Golang

Functionalities to be supported:

  • build server
  • start server
  • stop server
  • show server status
  • kill server
  • reload games or a specified game

The command name should be goworld(.exe), and can use go get to install to $GOPATH

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.