GithubHelp home page GithubHelp logo

surparallel / luacluster Goto Github PK

View Code? Open in Web Editor NEW
306.0 7.0 62.0 50.13 MB

MMO game server: Unity includes a 10,000 Player scene

License: GNU Affero General Public License v3.0

Lua 2.31% Makefile 0.20% C 81.79% Shell 0.41% M4 0.17% C++ 0.36% Perl 11.17% HTML 1.81% Roff 0.02% CSS 0.03% TeX 0.05% PostScript 0.01% Batchfile 0.06% Pascal 0.15% DIGITAL Command Language 0.07% Assembly 0.63% XS 0.02% eC 0.01% Emacs Lisp 0.01% CMake 0.72%
gameserver luajit lua distributed-systems multithreading luacluster

luacluster's Introduction

luacluster

C/C++ CI

概要

luacluster分布式游戏服务器框架。特色是实现了万人同屏,实现了无缝大地图,用户开发方式为lua的rpc调用模式,已经接入mongodb。近期计划是写技术白皮书。QQ群:927073440。

Lucluster distributed game server framework. The feature is to achieve the same screen for ten thousand people and a big seamless world. The user development mode is the rpc call mode of lua. Mongodb is already available. The immediate plan is to write a technical white paper.

1. BUILDING AND INSTALLATION

CMake (Windows)

Install CMake: https://www.cmake.org

$ md build && cd build
$ cmake -G "Visual Studio 10" ..   # Or use any generator you want to use. Run cmake --help for a list
$ cmake --build . --config Release # Or "start libevent.sln" and build with menu in Visual Studio.

See Documentation/Building#Building on Windows for more information

CMake (Ubuntu 18,20)

$ apt-get install -y build-essential libreadline-dev
$ cd core && mkdir build
$ cd core/build && cmake ..     # Default to ubuntu Makefiles.
$ cd core && cmake --build build

CMake (optional)

$ cmake -DLUA_USE_LUAJIT=ON #使用luajit

2. START RUNING (Windows)

服务器

启动流程:redis.bat, luacluter(_d).exe, bots.bat

在bots.bat中修改要启动的机器人数量

机器人

# --btcp的参数为连接服务器的 Ip port 总数量
$ luacluter_d.exe --bots --noudp --inside --btcp 127.0.0.1 9577 500 #服务器ip, 端口,总数量

# --btcp2的参数为连接服务器的 Ip port 数量 ip数量
$ luacluter_d.exe --bots --noudp --inside --btcp2 127.0.0.1 9577 500 #服务器ip, 端口,数量, ip的数量

两种模式的配置

服务器的默认配置文件core\res\server\config_defaults.json

压力测试模式

{
  "log_config": {
    "ruleDefault": {

    }
  },
  "base_config": {
    "inside": 1
  },
  "docke_config":{
    "dockerRandomSize":128,#随机线程的数量
    "dockerGlobeSize":8,#全局线程的数量
    "popNodeSize":200000,
    "congestion":4000000
  },
  "tcp":{
    "tcp4":[
      {
      "tcp4BindAddr":"0.0.0.0",#tcp的线程和ip端口
      "tcp4Port":9577
      }, 
      {
      "tcp4BindAddr":"0.0.0.0",
      "tcp4Port":9578
      }, 
      {
      "tcp4BindAddr":"0.0.0.0",
      "tcp4Port":9579
      }, 
      {
      "tcp4BindAddr":"0.0.0.0",
      "tcp4Port":9580
      }, 
      {
      "tcp4BindAddr":"0.0.0.0",
      "tcp4Port":9581
      }, 
      {
      "tcp4BindAddr":"0.0.0.0",
      "tcp4Port":9582
      }, 
      {
      "tcp4BindAddr":"0.0.0.0",
      "tcp4Port":9583
      }, 
      {
      "tcp4BindAddr":"0.0.0.0",
      "tcp4Port":9584
      }, 
      {
      "tcp4BindAddr":"0.0.0.0",
      "tcp4Port":9585
      }, 
      {
      "tcp4BindAddr":"0.0.0.0",
      "tcp4Port":9586
      }
    ]
  }
}

单线程调试模式

{
  "log_config": {
    "ruleDefault": {

    }
  },
  "base_config": {
    "inside": 1
  },
  "docke_config":{
    "dockerRandomSize":1,#随机线程的数量
    "dockerGlobeSize":0,#全局线程的数量
    "popNodeSize":200000,
    "congestion":4000000
  },
  "tcp":{
    "tcp4":[
      {
      "tcp4BindAddr":"0.0.0.0",#tcp的线程和ip端口
      "tcp4Port":9577
      }
    ]
  }
}

数据库存储的测试

在luacluster中使用mongodb

sc.lua全局配置中已经添加了"dbsvr"全局服务对象。

sc.cluster.serves = {"space","bigworld","dbsvr"}--集群启动时要启动的服务列表

在任意节点控制台输入命令创建一个dbentity对象

#命令new
#参数1:在什么地方创建对象
	DockerCurrent = 0, //当前线程的docker
	DockerRandom,//当前节点的随机ddocker
	NodeInside,//任意内部节点
	NodeOutside,//任意有对外部通信节点
	NodeRandom,//随机节点
	DockerGlobe//放入全局对象池
#参数2:创建对象的名字“dbentity”
#参数3:创建对象的初始化数据格式为json
>new 1 dbentity {}
>New tentity:   18302840717262782469

使用call命令调用dbentity对象的fun函数返回dbid。

>call 18302840717262782469 fun
>test entity fun
db      6253f48671099513a0f5165f

#命令call
#参数1:entityid
#参数2:entity的函数,这里为dbentity.lua中的“fun”
#剩余参数:为函数参数,类型为数字,字符串,json。例如call 18302840717262782469 fun2 111 {"a":1} aaa

3. luacluster白皮书纲要

  1. luacluster组织架构及名词定义
  2. entity对象的创建,继承,多重继承,多态,健事件。
  3. luarpc调用及封包结构。
  4. 全局对象的创建和全局对象的功能插件
  5. bigworld无缝大地图全局对象。
  6. sudoku九宫格空间全局对象。
  7. space全局对象
  8. dbsvr数据存储全局对象
  9. 命令以及参数
  10. docker的脚本api
  11. 如何使用luacluster创建一个MMO游戏

luacluster's People

Contributors

gantleman 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

luacluster's Issues

windows下编译

windows下编译少了 cd core
cd core && md build && cd build

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.