goworld

package module
v0.0.0-...-fae5011 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

README

GoWorld GoDoc Build Status

Scalable Distributed Game Server Engine with Hot Swapping in Golang

Working towards alpha

QQ群:662182346 中文站点:http://goworldgs.com/?p=64



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

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 responsable for handling client connections and receive/send packets from/to clients. The games manages all entities and runs all game logic. The dispatcher is responsable for redirecting packets among games and between games and gates.

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

Get GoWorld

Download goworld:

get github.com/xiaonanln/goworld

Install dependencies

go get -u github.com/xiaonanln/go-xnsyncutil/xnsyncutil
go get -u github.com/xiaonanln/goTimer
go get -u github.com/xiaonanln/typeconv
go get -u golang.org/x/net/context
go get -u github.com/Sirupsen/logrus
go get -u github.com/garyburd/redigo/redis
go get -u github.com/google/btree
go get -u github.com/pkg/errors
go get -u gopkg.in/eapache/queue.v1
go get -u gopkg.in/ini.v1
go get -u gopkg.in/mgo.v2
go get -u gopkg.in/vmihailenco/msgpack.v2
go get -u gopkg.in/natefinch/lumberjack.v2

Run Example Server & Client

  1. Get MongoDB or Redis Running

  2. Copy goworld.ini.sample to goworld.ini, and configure accordingly

    cp goworld.ini.sample goworld.ini
    
  3. Build and run dispatcher:

    make dispatcher
    components/dispatcher/dispatcher
    
  4. Build and run gate:

    make gate
    components/gate/gate -gid 1
    
  5. Build and run test_game:

    make test_game
    examples/test_game/test_game -gid 1
    
  6. Build and run test_client:

    make test_client
    examples/test_client/test_client -N 500
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEntityAnywhere

func CreateEntityAnywhere(typeName string)

Create a entity on any server

func CreateEntityLocally

func CreateEntityLocally(typeName string) EntityID

Create a entity on the local server

returns EntityID

func CreateSpaceAnywhere

func CreateSpaceAnywhere(kind int)

Create a space with specified kind in any game server

func CreateSpaceLocally

func CreateSpaceLocally(kind int) EntityID

Create a space with specified kind in the local game server

returns the space EntityID

func Exists

func Exists(typeName string, entityID EntityID, callback storage.ExistsCallbackFunc)

Check if entityID exists in entity storage

returns result in callback

func GetEntity

func GetEntity(id EntityID) *entity.Entity

Get entity by EntityID

func GetGameID

func GetGameID() uint16

Get the local server ID

server ID is a uint16 number starts from 1, which should be different for each servers server ID is also in the game config section name of goworld.ini

func GetServiceProviders

func GetServiceProviders(serviceName string) entity.EntityIDSet

Get the set of EntityIDs that provides the specified service

func ListAttr

func ListAttr() *entity.ListAttr

Create a new ListAttr

func ListEntityIDs

func ListEntityIDs(typeName string, callback storage.ListCallbackFunc)

Get all saved entity ids in storage, may take long time and block the main routine

returns result in callback

func LoadEntityAnywhere

func LoadEntityAnywhere(typeName string, entityID EntityID)

Load the specified entity from entity storage

func MapAttr

func MapAttr() *entity.MapAttr

Creates a new MapAttr

func RegisterEntity

func RegisterEntity(typeName string, entityPtr entity.IEntity) *entity.EntityTypeDesc

Register the entity type

returns the entity type description object which can be used to define more properties of entity type

func RegisterSpace

func RegisterSpace(spacePtr entity.ISpace)

Register the space entity type

All spaces will be created as an instance of this type

func Run

func Run(delegate game.IGameDelegate)

Run the server

This is the main routine for the server and all entity logic, and this function never quit

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL