Git Product home page Git Product logo

atsf4g-co's Introduction

atsf4g-co

service framework for game server using libatbus, libatapp, libcopp and etc.

Inner Service

  • atproxy : proxy for logic server to communicate with each other

    • using etcd for service discovery and online detection.
  • atgateway : gateway for client to communicate logic server

    • Using DH/ECDH for key establishment(directly send key or no encryption are also supported)
    • Traffic control and handshake timeout available for each client
    • Support for routing switching

Dependency

  1. libuv -- libuv is a multi-platform support library with a focus on asynchronous I/O.
  2. msgpack-c -- MessagePack is an efficient binary serialization format, and msgpack-c is a c and c++ driver for it.
  3. libiniloader -- a small and lightweight ini loader code.
  4. libcurl -- libcurl is a free and easy-to-use client-side URL transfer library
  5. libcopp -- Cross-platform coroutine library written in c++.
  6. rapidjson -- A fast and header only json library.
  7. flatbuffer -- A simple pack/unpack library. It's used in atgateway's inner protocol.

Prepare

  1. Install etcd. (It's used for atproxy to connect to each other.)
  2. [opional] Install redis. (DB services.install it if used)

Extern Dependency

  1. libuuid-devel(uuid-dev)
  2. [opional] hiredis, redis (if using redis, full_sample branch has use redis)

Basic Usage

Build on Windows

You need to prebuilt all dependency libraries such as openssl/mbedtls, libcurl, libuv and so on. Then run

mkdir build_jobs_msvc
cd build_jobs_msvc
# run cmake
cmake [SOURCE PATH] -G "Visual Studio ... Win64" -DLIBUV_ROOT=[LIBUV INSTALL PATH] -DOPENSSL_ROOT=[OPENSSL INSTALL PATH] -DPROJECT_ENABLE_UNITTEST=YES -DPROJECT_ENABLE_SAMPLE=YES -DPROJECT_ENABLE_TOOLS=YES ...

cd build_jobs_msvc

cmake --build . --config Debug

Please see 3rd_party to see which libraries is required.

Build on Unix like system

# auto setup cmake

sh cmake_dev.sh [options] ...

# we will generate directory build_jobs_$(basename $(uname -s)) for build and place publish directory
cd build_jobs_*

# just build with make -j4 or ninja -j4
cmake --build . -- -j4

Such as sh cmake_dev.sh -su to enable all unit test and samples, or sh cmake_dev.sh -a to use clang-analysis. You can also directly run cmake [SOURCE PATH] [options...] just like in windows, use your own prebuilt libraries or not. It depends to you.

All resource and file will be put into <BUILD_DIR>/publish after compile completed.

Configure & Run

Configure file is placed on <BUILD_DIR>/publish/tools/script/config.conf just edit it and set your etcd server and DB configure, then run <BUILD_DIR>/publish/tools/script/gen_conf.py to generate all configure files and scripts for servers. restart_all.shstop_all.shreload_all.sh script files will also be generated for easy usage.

cd publish/tools/script

vim config.conf # edit configure

python3 gen_conf.py

./restart_all.sh

gen_conf.py also has options for set some configures instead of using it in config.conf, it's useful when integration our server into other management system. Use python3 ./gen_conf.py - --help for more help information.

Developer

Tools

  1. cmake 3.7 and above
  2. gcc/clang/msvc
  3. gdb/lldb/windb
  4. git
  5. unzip
  6. tar
  7. autoconf
  8. automake
  9. p7zip
  10. python2/python
  11. etc.

Python modules

  1. python-mako/python*-mako/mingw-w64-x86_64-python*-mako
  2. [optional] python-setuptools/python*-setuptools/mingw-w64-x86_64-python*-mako
  3. [optional] python-pip/python*-pip/mingw-w64-x86_64-python*-pip

Framework Code Tree

  • 3rd_party: all dependency 3rd_party libraries
  • atframework: atframework projects and libraries
  • export: exported libraries, used by client
  • libatframe_utils: framework utility codes
  • libatbus: communication library used between servers
  • libatapp: server application framework, used to build a specified server type
  • services: inner services of atframework
  1. component: inner services common codes
  2. atproxy: proxy server, used to connect difference service group to each other
  3. atgateway: gateway server, used to manage client connections
  • doc: documents
  • install: all resources and configure templates
  • project: project script, used to detect build environment and generate build scripts
  • sample: sample codes to show usage of some libraries
  • src: all real projects
  • echosvr: the simplest server instance, just send back all data receive from client
  • [others]: other services

Logic Code Tree

  • src: all real projects
  • server_frame: server common library
  1. config: server configure defines and excel configure data structures
  2. data: game data layer
  3. dispatcher: decide how to deal with each type of messages and manage coroutine tasks
  4. logic: game logic layer
  5. rpc: all remote procedure call APIs, include server to server message, DB message and so on
  6. utility: all shared utility codes
  • tools: tool projects

Basic Usage

Build on Windows

You need to prebuilt all dependency libraries such as openssl/mbedtls, libcurl, libuv and so on. Then run

mkdir build_jobs_msvc
cd build_jobs_msvc
# run cmake
cmake [SOURCE PATH] -G "Visual Studio ... Win64" -DLIBUV_ROOT=[LIBUV INSTALL PATH] -DOPENSSL_ROOT=[OPENSSL INSTALL PATH] -DPROJECT_ENABLE_UNITTEST=YES -DPROJECT_ENABLE_SAMPLE=YES -DPROJECT_ENABLE_TOOLS=YES ...

cd build_jobs_msvc

cmake --build . --config Debug

Please see 3rd_party to see which libraries is required.

Build on Unix like system

# auto setup cmake

sh cmake_dev.sh [options] ...

# we will generate directory build_jobs_$(basename $(uname -s)) for build and place publish directory
cd build_jobs_*

# just build with make -j4 or ninja -j4
cmake --build . -- -j4

Such as sh cmake_dev.sh -su to enable all unit test and samples, or sh cmake_dev.sh -a to use clang-analysis. You can also directly run cmake [SOURCE PATH] [options...] just like in windows, use your own prebuilt libraries or not. It depends to you.

All resource and file will be put into <BUILD_DIR>/publish after compile completed.

Configure

Configure file is placed on <BUILD_DIR>/publish/tools/script/config.conf just edit it and set your etcd server and DB configure, then run <BUILD_DIR>/publish/tools/script/gen_conf.py to generate all configure files and scripts for servers. restart_all.shstop_all.shreload_all.sh script files will also be generated for easy usage.

cd publish/tools/script

vim config.conf # edit configure

python3 gen_conf.py

./restart_all.sh

gen_conf.py also has options for set some configures instead of using it in config.conf, it's useful when integration our server into other management system. Use python3 ./gen_conf.py - --help for more help information.

At last, you can use <BUILD_DIR>/publish/tools/simulator/bin/simulator-cli to connect gateway and send/receive messages.

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.