A cross-platform,lightweight,scalable game server framework written in C++, and support Lua Script

Overview

Current building status

linux-gcc

linux-clang

macos-clang

windows-vs2019

Moon

Moon is a lightweight online game server framework implement with multithread and multi-luaVM. One thread may have 1-N luaVM, they use message queue communication. There are many features for game server development:

  • Less core code, easy to learn
  • Cross-platform (Windows, Linux, MacOS)
  • Optimized networking
    • tcp
    • websockets
    • http
  • Lua coroutine based asynchronous
    • coroutine-socket
    • timer
    • inter luaVM communication
    • inter cluster(process) communication
    • redis/mysql/pgsql driver
  • High performance and optimized Lua Json library
  • Lua protobuf library
  • Lua filesystem

OverView

image

Community

  • Gitter

  • QQ group: 543833695

Documents

https://github.com/sniper00/moon/wiki

Dependencies

Quick Start

Download Pre-Built Binaries

https://github.com/sniper00/moon/releases

# run echo server
./moon example/helloworld.lua
# another terminal run client(coroutine socket writed)
./moon example/helloworld_client.lua
# input any string

Manual Build

  1. Make sure your compiler(msvc2019, gcc 9.3+, clang 9.0+) support for C++17 or Install C++17 Compiler.

  2. Moon uses premake5 to build platform specific projects. Download it and make sure it's available on your path.

  3. Clone source code

    git clone https://github.com/sniper00/moon.git
  1. Build

    • windows run build.bat
    • linux:
          chmod +x build.sh
          chmod +x premake5
          ./build.sh

    If failed,See detail steps

Demo

Friend Open Source

NoahGameFrame

  • Author: ketoo
  • GitHub: https://github.com/ketoo/NoahGameFrame
  • Description: A fast, scalable, distributed game server framework for C++, include actor library, network library,can be used as a real time multiplayer game engine ( MMO RPG ), which plan to support C#/Python/Lua script, and support Unity3d, Cocos2dx, FlashAir client access.
You might also like...
Lightweight, cross-platform & full-featured shader IDE
Lightweight, cross-platform & full-featured shader IDE

SHADERed is a lightweight tool for writing and debugging shaders. It is easy to use, open source, cross-platform (runs on Windows, Linux & Web).

Plua is a superset of Lua for classic PalmOS devices with added support for graphics, UI, networking, events and sound.

Plua2c Plua is a superset of Lua for classic PalmOS devices with added support for graphics, UI, networking, events and sound. This is the source code

Dynamic 3D cellular automata engine with lua scripting support
Dynamic 3D cellular automata engine with lua scripting support

Cell3D Cell3D is a dynamic 3D cellular automata engine with lua scripting support Installation Dependencies: Lua 5.3 Raylib Simplest possible build co

Free,Open-Source,Cross-platform agent and Post-exploiton tool written in Golang and C++, the architecture and usage like Cobalt Strike
Free,Open-Source,Cross-platform agent and Post-exploiton tool written in Golang and C++, the architecture and usage like Cobalt Strike

Khepri Free,Open-Source,Cross-platform agent and Post-exploiton tool written in Golang and C++ Description Khepri is a Cross-platform agent, the archi

Unicorn is a lightweight, multi-platform, multi-architecture CPU emulator framework, based on QEMU.
Unicorn is a lightweight, multi-platform, multi-architecture CPU emulator framework, based on QEMU.

Unicorn Engine Unicorn is a lightweight, multi-platform, multi-architecture CPU emulator framework, based on QEMU. Unicorn offers some unparalleled fe

The Leap Motion cross-format, cross-platform declarative serialization library

Introduction to LeapSerial LeapSerial is a cross-format, declarative, serialization and deserialization library written and maintained by Leap Motion.

A cross-platform framework for developing spatial audio algorithms and software in C/C++

git: https://github.com/leomccormack/Spatial_Audio_Framework doxygen: https://leomccormack.github.io/Spatial_Audio_Framework/ About The Spatial_Audio_

A fully-featured, cross platform XO-CHIP/S-CHIP/CHIP-8 emulator written in C and SDL.
A fully-featured, cross platform XO-CHIP/S-CHIP/CHIP-8 emulator written in C and SDL.

JAXE (Just Another XO-CHIP/CHIP-8 Emulator) Brix Space Invaders (In Debug Mode) Black Rainbow DVN8 Super Neat Boy Chicken Scratch CHIP-8 was a virtual

A cross platform shader language with multi-threaded offline compilation or platform shader source code generation
A cross platform shader language with multi-threaded offline compilation or platform shader source code generation

A cross platform shader language with multi-threaded offline compilation or platform shader source code generation. Output json reflection info and c++ header with your shaders structs, fx-like techniques and compile time branch evaluation via (uber-shader) "permutations".

Comments
  • moon.new_service是怎么返回服务id的?

    moon.new_service是怎么返回服务id的?

    moon.new_service这个api是怎么获得服务id并返回的? 看了好久也没有捋清楚. math.tointeger(co_yield()) 不是应该挂起当前协程么?

    我写了个例子, 我理解的是moon.new_service 执行完都需要再次执行coroutine.resume才能把for循环跑完. 因为new_service最后yield的了? 但是实际是for循环是一次都执行完了,并没有中途挂起, 而且返回了服务id. 一直也没有看懂这服务id怎么来的. 求帮忙讲解一下.

    moon.async(function()
        local conf = {
            base_name = "gate",
            file = "service_gate.lua",
            host = "0.0.0.0",
            base_port = 20520,
            num = 5,
            unique = true, -- 通过name做唯一区分,name不能相同
        }
    
        for i = 1, conf.num do
            conf.port = conf.base_port + i - 1
            conf.name = conf.base_name .. i
            local r = moon.new_service("lua", conf)
        end
    end)
    
    opened by axiullo 3
  • 求助:查询mysql遇到问题.

    求助:查询mysql遇到问题.

    我结合hello world例程和mysql例程写了一个测试使用mysql例程. 功能简单, 若接收到客户端发来的指定字符串'dbtest' 就从mydb中查询所有表名, 其结果直接发送给客户端作为回复. 代码如下 image image 报错如下: image

    1. 在on message里直接写mysql连接查询 就会报错, 所以只能在协程里写.
    2. 在协程中写, 本框架不能使用全局变量, 所以函数必须传参. 这种情况下该怎么传参到匿名函数中? 卡了很久了, 网上搜不到, lua的pdf我也下了看, 但我还是不知道这种该怎么写, 求助一下.
    opened by warm-dawn 2
  • fix compilation error

    fix compilation error

    gcc version 12.2.0 编译有报错

    lua_json.cpp In file included from ../../../lualib-src/lua_json.cpp:6: ../../../common/buffer.hpp: In constructor ‘moon::base_buffer::base_buffer(moon::base_buffer&&)’: ../../../common/buffer.hpp:166:26: error: ‘exchange’ is not a member of ‘std’ 166 | , flag_(std::exchange(other.flag_, 0)) | ^~~~~~~~ ../../../common/buffer.hpp:167:34: error: ‘exchange’ is not a member of ‘std’ 167 | , headreserved_(std::exchange(other.headreserved_, 0)) | ^~~~~~~~ ../../../common/buffer.hpp:168:30: error: ‘exchange’ is not a member of ‘std’ 168 | , capacity_(std::exchange(other.capacity_, 0)) | ^~~~~~~~ ../../../common/buffer.hpp:169:29: error: ‘exchange’ is not a member of ‘std’ 169 | , readpos_(std::exchange(other.readpos_, 0)) | ^~~~~~~~ ../../../common/buffer.hpp:170:30: error: ‘exchange’ is not a member of ‘std’ 170 | , writepos_(std::exchange(other.writepos_, 0)) | ^~~~~~~~ ../../../common/buffer.hpp:171:26: error: ‘exchange’ is not a member of ‘std’ 171 | , data_(std::exchange(other.data_, nullptr)) | ^~~~~~~~ ../../../common/buffer.hpp: In member function ‘moon::base_buffer& moon::base_buffer::operator=(moon::base_buffer&&)’: ../../../common/buffer.hpp:180:30: error: ‘exchange’ is not a member of ‘std’ 180 | flag_ = std::exchange(other.flag_, 0); | ^~~~~~~~ ../../../common/buffer.hpp:181:38: error: ‘exchange’ is not a member of ‘std’ 181 | headreserved_ = std::exchange(other.headreserved_, 0); | ^~~~~~~~ ../../../common/buffer.hpp:182:34: error: ‘exchange’ is not a member of ‘std’ 182 | capacity_ = std::exchange(other.capacity_, 0); | ^~~~~~~~ ../../../common/buffer.hpp:183:33: error: ‘exchange’ is not a member of ‘std’ 183 | readpos_ = std::exchange(other.readpos_, 0); | ^~~~~~~~ ../../../common/buffer.hpp:184:34: error: ‘exchange’ is not a member of ‘std’ 184 | writepos_ = std::exchange(other.writepos_, 0); | ^~~~~~~~ ../../../common/buffer.hpp:185:30: error: ‘exchange’ is not a member of ‘std’ 185 | data_ = std::exchange(other.data_, nullptr); | ^~~~~~~~ make[1]: *** [Makefile:182: ../../obj/lualib/Debug/lua_json.o] Error 1 make: *** [Makefile:75: lualib] Error 2

    opened by lchannng 0
Owner
Bruce
Bruce
C/C++ language server supporting multi-million line code base, powered by libclang. Emacs, Vim, VSCode, and others with language server protocol support. Cross references, completion, diagnostics, semantic highlighting and more

Archived cquery is no longer under development. clangd and ccls are both good replacements. cquery cquery is a highly-scalable, low-latency language s

Jacob Dufault 2.3k Jan 2, 2023
A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.

Turbo Vision A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support. I

null 1.4k Dec 31, 2022
🔥 A cross-platform build utility based on Lua

xmake A cross-platform build utility based on Lua Modern C/C++ build tools, Simple, Fast, Powerful dependency package integration Supporting the proje

xmake-io 6.1k Jan 4, 2023
The Lua development repository, as seen by the Lua team. Mirrored irregularly

The Lua development repository, as seen by the Lua team. Mirrored irregularly

Lua 6.4k Jan 5, 2023
A dependency free, embeddable debugger for Lua in a single file (.lua or .c)

debugger.lua A simple, embedabble debugger for Lua 5.x, and LuaJIT 2.x. debugger.lua is a simple, single file, pure Lua debugger that is easy to integ

Scott Lembcke 600 Dec 31, 2022
Cross-platform sandbox RPG game written in C++ with OpenGL and SDL2.

Forradia test Forradia is a cross-platform sandbox survival/RPG game written in C++ with OpenGL and SDL2. The engine loads 3D models in Wavefront-form

Andreas Åkerberg 7 Nov 9, 2022
Cross-platform GPU-oriented C++ application/game framework

Introduction neoGFX is a C++ app/game engine and development platform targeted at app and game developers that wish to leverage modern GPUs for perfor

i42 Software 470 Dec 13, 2022
SMARTmBOT - a new, customizable, scalable, and fully opensource mobile robot platform

The goal of this repository is to introduce a new, customizable, scalable, and fully opensource mobile robot platform, called SMARTmBOT. This repository provides a guide, and all design files and source codes so that you can build your own SMARTmBOT. SMARTmBOT can be useful for studying the basics of robotics, especially mobile robotics. It can also be used to study advanced topics such as swarm robotics.

SMART Lab at Purdue University 39 Jan 2, 2023
FireDog - Open source cross-platform lightweight virus signature detection engine.

FireDog 开源跨平台轻量级病毒特征检测引擎。Open source cross-platform lightweight virus signature detection engine. 语言 Language C++ 11 LICENSE 是你们喜欢的:MIT License. 让我们搞起

null 41 Nov 4, 2022
A lightweight & cross-platform IDE supporting the most recent C++ standards

This project has moved to https://gitlab.com/cppit/jucipp. juCi++ a lightweight, platform independent C++-IDE with support for C++11, C++14 and C++17

cppit (zippit) 886 Jan 3, 2023