3.1 KiB
Executable File
SIO Client
This SIO client depends on websocket++ and rapidjson, it provides a C++ client implementation for Socket.IO and is inspired by the socket.io-clientpp project. This library is able to connect to a Socket.IO 1.0 server.
C++ allows amazing possibilities for cross platform development. Here's a screenshot showing example apps (iPhone,QT,Console and web) chatting in one room.
Socket.IO 1.0+ protocol has been implemented!
The code is compatible with 1.0+ protocol only, not with prior protocols.
C++11 only for now
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.
Supported features
- 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.
Usage
- Make sure you have the boost libraries 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.
Boost build instructions(Build the necessary subset only)
- 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 release
For 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 stage
For 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 stage
Finally, 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.
