A C++ server framework for mobile game development, integrating tinynet, Google Protobuf, MongoDB, and other components.
git clone git@github.com:yuyunliuhen/server_framework.git
git clone git@github.com:yuyunliuhen/tinynet.git
git clone git@github.com:yuyunliuhen/easy.gitInstall Boost
- Download from Boost binaries
- Recommended version: 1.53 for VS2012
Install SCons
- Download from SCons website
- Latest version: 2.3.3
Build MongoDB C++ Driver
git clone https://github.com/mongodb/mongo-cxx-driver.git cd easy/dep/mongo-cxx-driver scons --cpppath="C:\local\boost_1_53_0" --libpath="C:\local\boost_1_53_0\lib64-msvc-11.0" --64 --sharedclient --dynamic-windows --dbg=on
See MongoDB Windows Guide for details.
Build Jansson
Open easy/dep/jansson/win32/vs2012/jansson.sln and buildBuild Protobuf
Open easy/dep/protobufvsprojects/protobuf.sln and buildBuild Server Framework
# Generate protocol files general_proto_64.bat # Using VS2012 x64 Cross Tools Command Prompt cmake -G "Visual Studio 11 Win64". msbuild.exe ALL_BUILD.vcxproj
Build Boost
# Download from http://www.boost.org/ tar zxvf boost_1_49_0.tar.gz cd boost_1_49_0 ./bootstrap.sh ./b2 install
Install SCons
# Download from http://www.scons.org/ tar zxvf scons-2.3.3.tar.gz cd scons-2.3.3 python setup.py install
Build Dependencies
# Protobufcd easy/dep/protobuf ./configure && make # Janssoncd easy/dep/jansson ./configure && make # MongoDBcd mongo-cxx-driver scons all # For custom boost path:# scons --cpppath="/home/lee/install/include" --libpath="/home/lee/install/lib"
See Google Protobuf Guide and MongoDB Linux Guide for details.
Build Server Framework
cd server_framework cmake .# For debug: cmake -DCMAKE_BUILD_TYPE=Debug . make
Alternative: Use build scripts
- Windows:
build_x64.batorbuild_x86.bat(Visual Studio 2012+) - Linux:
build.sh(GCC 4.8.1+)
Note: All dependency libraries are pre-built in the dep directory.
The configuration file is located at config/servers_template.json. You can add or remove core/proxy servers as needed.
Set environment variables using env.sh, then:
./bin/core 192.168.20.135 8881
./bin/core 192.168.20.135 8882
./bin/proxy 192.168.20.135 8871
./bin/proxy 192.168.20.135 8872
./bin/login 192.168.20.135 8861
# Test client
./bin/test_client 192.168.20.135 8861