This SIO client is depends on websocket++ and rapidjson, it provides another C++ client implementation for Socket.IO. This library is able to connect to a Socket.IO server 1.0, and the initial thought of writing it is inspired by the socket.io-clientpp project.
C++ has amazing abilities to cross platform, there's a screen shot about using all example apps (iPhone,QT,Console and web) in this project to chat in one room.
The code is compatible with 1.0+ protocol only, not with prior protocols.
C++11 saves much time for me, so this is C++11 only for the first version. I'll do further compatibility efforts on demand.
- Internal thread manangement.
- Sends plain text messages.
- Sends binary messages.
- Sends structured messages with text and binary all together.
- Sends messages with an ack and its corresponding callback.
- Receives messages and automatically sends customable ack if need.
- Automatically ping/pong messages and timeout management.
- Reconnection.
- Make sure you have the boost libararies installed.
- Include websocket++, rapidjson and
sio_client.cpp,sio_packet.cppin your project. - Include
sio_client.hwhere you want to use it. - Use
messageand its derived classes to compose complex text/binary messages.
- Download boost from boost.org.(suppose we downloaded boost 1.55.0)
- Unpack boost to some place.(such as D:\boost_1_55_0)
- Run either .\bootstrap.bat (on Windows), or ./bootstrap.sh (on other operating systems) under boost folder(D:\boost_1_55_0).
- Run ./b2 install --prefix=PREFIX where PREFIX is a directory where you want Boost.Build to be installed.
- Optionally, add PREFIX/bin to your PATH environment variable.
- Build needed boost modules, with following command line as an example:
For Windows:
bjam stage --toolset=msvc --with-system --with-date_time --with-thread --with-regex --with-serialization --with-random --stagedir="D:\boost_1_55_0\boost_build\release" link=static runtime-link=shared threading=multi releaseFor iOS
bjam -j16 --with-system --with-date_time --with-thread --with-regex --with-serialization --with-random --build-dir=iphone-build --stagedir=iphone-build/stage --prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-`${IPHONE_SDKVERSION}` define=_LITTLE_ENDIAN link=static stageFor Mac OSX
b2 -j16 --with-system --with-date_time --with-thread --with-regex --with-serialization --with-random --build-dir=osx-build --stagedir=osx-build/stage toolset=clang cxxflags="-std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" linkflags="-stdlib=libc++" link=static threading=multi stageFinally, Add boost source folder to header search path, and add static libs to link option.
sio client specific source is released under the BSD license.
