Skip to content

Commit a2dd8e1

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: docs: update compatibility table for Socket.IO v4 docs: fix title format (socketio#297) feat: allow resource path to be set in connection URI (socketio#134) fix: resolve client_impl::ping LOG call syntax in debug builds fix: resolve socketio#254: handle closing sockets upon on_fail events fix: lower the minimum CMake supported version feat: implement socketio#45: add support for logging configuration feat: add support for Socket.IO v3 refactor: use correct Engine.IO protocol revision refactor: use standard install paths (socketio#58) ci: migrate to GitHub Actions chore: update .gitignore with cmake output refactor: remove Boost dependency (socketio#176)
2 parents 8cdd9f9 + 0581aab commit a2dd8e1

25 files changed

+595
-371
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * 0'
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
fail-fast: false
16+
steps:
17+
- name: Checkout
18+
uses: actions/[email protected]
19+
20+
- name: Build project
21+
uses: nicledomaS/[email protected]
22+
with:
23+
submodule_update: ON
24+
run_tests: ON
25+
unit_test_build: -DBUILD_UNIT_TESTS=ON
26+
cmake_args: -DCMAKE_CXX_FLAGS=-std=c++11

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
build/
2-
**/*.user
2+
**/*.user
3+
4+
CMakeCache.txt
5+
CMakeFiles/
6+
Makefile
7+
cmake_install.cmake
8+
install_manifest.txt
9+
libsioclient.a

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
[submodule "lib/rapidjson"]
55
path = lib/rapidjson
66
url = https://github.com/miloyip/rapidjson.git
7+
[submodule "lib/asio"]
8+
path = lib/asio
9+
url = https://github.com/chriskohlhoff/asio.git
10+
[submodule "lib/catch"]
11+
path = lib/catch
12+
url = https://github.com/philsquared/Catch.git

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

API.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ Set listener for reconnecting is in process.
168168

169169
Set listener for reconnecting event, called once a delayed connecting is scheduled.
170170

171+
#### Logs
172+
`void set_logs_default()`
173+
174+
Configure logs to the default level (connect, disconnect, app)
175+
176+
`void set_logs_quiet()`
177+
178+
Configure logs to the quiet level
179+
180+
`void set_logs_verbose()`
181+
182+
Configure logs to the verbose level
183+
171184
#### Namespace
172185
`socket::ptr socket(std::string const& nsp)`
173186

BOOST.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
22
PROJECT(sioclient)
33

44
option(BUILD_SHARED_LIBS "Build the shared library" OFF)
5-
option(Boost_USE_STATIC_LIBS "Use Boost static version" ON)
5+
option(BUILD_UNIT_TESTS "Builds unit tests target" OFF)
66

77
set(MAJOR 1)
88
set(MINOR 6)
@@ -16,27 +16,35 @@ MESSAGE(SEND_ERROR "CMAKE_BUILD_TYPE must be either Release or Debug")
1616
return()
1717
endif()
1818

19-
set(BOOST_VER "1.55.0" CACHE STRING "boost version" )
20-
21-
set(Boost_USE_MULTITHREADED ON)
22-
set(Boost_USE_STATIC_RUNTIME OFF)
23-
find_package(Boost ${BOOST_VER} REQUIRED COMPONENTS system date_time random)
24-
2519
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src ALL_SRC)
2620
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src/internal ALL_SRC)
2721
file(GLOB ALL_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/*.h )
2822
set(SIO_INCLUDEDIR ${CMAKE_CURRENT_LIST_DIR})
2923

24+
add_definitions(
25+
# These will force ASIO to compile without Boost
26+
-DBOOST_DATE_TIME_NO_LIB
27+
-DBOOST_REGEX_NO_LIB
28+
-DASIO_STANDALONE
29+
# These will force WebsocketPP to compile with C++11
30+
-D_WEBSOCKETPP_CPP11_STL_
31+
-D_WEBSOCKETPP_CPP11_FUNCTIONAL_
32+
)
33+
3034
add_library(sioclient ${ALL_SRC})
31-
target_include_directories(sioclient PRIVATE ${Boost_INCLUDE_DIRS}
35+
target_include_directories(sioclient PRIVATE
3236
${CMAKE_CURRENT_LIST_DIR}/src
3337
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
3438
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
39+
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include
3540
)
3641

42+
if (CMAKE_VERSION VERSION_GREATER "3.1")
3743
set_property(TARGET sioclient PROPERTY CXX_STANDARD 11)
3844
set_property(TARGET sioclient PROPERTY CXX_STANDARD_REQUIRED ON)
39-
target_link_libraries(sioclient PRIVATE ${Boost_LIBRARIES})
45+
else()
46+
set_property(TARGET sioclient APPEND_STRING PROPERTY COMPILE_FLAGS "-std=c++11")
47+
endif()
4048
if(BUILD_SHARED_LIBS)
4149
set_target_properties(sioclient
4250
PROPERTIES
@@ -49,16 +57,21 @@ list(APPEND TARGET_LIBRARIES sioclient)
4957
find_package(OpenSSL)
5058
if(OPENSSL_FOUND)
5159
add_library(sioclient_tls ${ALL_SRC})
52-
target_include_directories(sioclient_tls PRIVATE ${Boost_INCLUDE_DIRS}
60+
target_include_directories(sioclient_tls PRIVATE
5361
${CMAKE_CURRENT_LIST_DIR}/src
5462
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
5563
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
64+
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include
5665
${OPENSSL_INCLUDE_DIR}
5766
)
5867

68+
if (CMAKE_VERSION VERSION_GREATER "3.1")
5969
set_property(TARGET sioclient_tls PROPERTY CXX_STANDARD 11)
6070
set_property(TARGET sioclient_tls PROPERTY CXX_STANDARD_REQUIRED ON)
61-
target_link_libraries(sioclient_tls PRIVATE ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} )
71+
target_link_libraries(sioclient_tls PRIVATE ${OPENSSL_LIBRARIES} )
72+
else()
73+
set_property(TARGET sioclient_tls APPEND_STRING PROPERTY COMPILE_FLAGS "-std=c++11")
74+
endif()
6275
target_compile_definitions(sioclient_tls PRIVATE -DSIO_TLS)
6376
if(BUILD_SHARED_LIBS)
6477
set_target_properties(sioclient_tls
@@ -71,14 +84,18 @@ list(APPEND TARGET_LIBRARIES sioclient_tls)
7184

7285
endif()
7386

87+
include(GNUInstallDirs)
88+
7489
install(FILES ${ALL_HEADERS}
75-
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/include"
90+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
7691
)
7792

7893
install(TARGETS ${TARGET_LIBRARIES}
79-
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/lib/${CMAKE_BUILD_TYPE}"
94+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
8095
)
8196

82-
install(FILES ${Boost_LIBRARIES}
83-
DESTINATION "${CMAKE_CURRENT_LIST_DIR}/build/lib/${CMAKE_BUILD_TYPE}"
84-
)
97+
if(BUILD_UNIT_TESTS)
98+
message(STATUS "Building with unit test support.")
99+
enable_testing()
100+
add_subdirectory(test)
101+
endif()

INSTALL.md

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,13 @@
11
## Install
22

33
### With CMake
4-
1. Install boost, see [Boost setup](#boost_setup) section.
5-
2. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
6-
3. Run `cmake -DBOOST_ROOT:STRING=<your boost install folder> -DBOOST_VER:STRING=<your boost version> ./`
7-
4. Run `make install`(if makefile generated) or open generated project (if project file generated) to build.
8-
5. Outputs is under `./build`, link with the all static libs under `./build/lib` and include headers under `./build/include` in your client code where you want to use it.
9-
10-
* If you're using boost without install,you can specify `boost include dir` and `boost lib dir` separately by:
11-
```bash
12-
cmake
13-
-DBOOST_INCLUDEDIR=<your boost include folder>
14-
-DBOOST_LIBRARYDIR=<your boost lib folder>
15-
-DBOOST_VER:STRING=<your boost version>
16-
./
17-
```
18-
* CMake didn't allow merging static libraries,but they're all copied to `./build/lib`, you can DIY if you like.
4+
1. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
5+
2. Run `cmake ./`
6+
3. Run `make install`(if makefile generated) or open generated project (if project file generated) to build.
7+
4. Outputs is under `./build`, link with the all static libs under `./build/lib` and include headers under `./build/include` in your client code where you want to use it.
198

209
### Without CMake
21-
1. Install boost, see [Boost setup](#boost_setup) section.
22-
2. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
23-
3. Add `<your boost install folder>/include`,`./lib/websocketpp` and `./lib/rapidjson/include` to headers search path.
24-
4. Include all files under `./src` in your project, add `sio_client.cpp`,`sio_socket.cpp`,`internal/sio_client_impl.cpp`, `internal/sio_packet.cpp` to source list.
25-
5. Add `<your boost install folder>/lib` to library search path, add `boost.lib`(Win32) or `-lboost`(Other) link option.
26-
6. Include `sio_client.h` in your client code where you want to use it.
27-
28-
## Boost setup
29-
30-
1. Download boost from [boost.org](http://www.boost.org/).
31-
1. Unpack boost to some place.
32-
1. Run either .\bootstrap.bat (on Windows), or ./bootstrap.sh (on other operating systems) under boost folder.
33-
34-
## Boost build (Build the necessary subset only)
35-
Windows (or other mainstream desktop platforms shall work too):
36-
37-
The following script will build the necessary subset:
38-
39-
```bash
40-
bjam install --prefix="<your boost install folder>" --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi
41-
```
42-
Optionally You can merge all output .lib files into a fat one, especially if you're not using cmake.
43-
44-
In output folder, run:
45-
46-
```bash
47-
lib.exe /OUT:boost.lib *
48-
```
10+
1. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
11+
2. Add `./lib/asio/asio/include`, `./lib/websocketpp` and `./lib/rapidjson/include` to headers search path.
12+
3. Include all files under `./src` in your project, add `sio_client.cpp`,`sio_socket.cpp`,`internal/sio_client_impl.cpp`, `internal/sio_packet.cpp` to source list.
13+
4. Include `sio_client.h` in your client code where you want to use it.

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
11
# Socket.IO C++ Client
2-
[![Build Status](https://travis-ci.org/socketio/socket.io-client-cpp.svg)](https://travis-ci.org/socketio/socket.io-client-cpp)
2+
3+
[![Build Status](https://github.com/socketio/socket.io-client-cpp/workflows/CI/badge.svg)](https://github.com/socketio/socket.io-client-cpp/actions)
34

45
By virtue of being written in C++, this client works in several different platforms. The [examples](https://github.com/socketio/socket.io-client-cpp/tree/master/examples) folder contains an iPhone, QT and Console example chat client! It depends on [websocket++](https://github.com/zaphoyd/websocketpp) and is inspired by [socket.io-clientpp](https://github.com/ebshimizu/socket.io-clientpp).
56

67
[![Clients with iPhone, QT, Console and web](https://cldup.com/ukvVVZmvYV.png)](https://github.com/socketio/socket.io-client-cpp/tree/master/examples)
78

9+
## Compatibility table
10+
11+
<table>
12+
<tr>
13+
<th rowspan="2">C++ Client version</th>
14+
<th colspan="2">Socket.IO server version</th>
15+
</tr>
16+
<tr>
17+
<td align="center">1.x / 2.x</td>
18+
<td align="center">3.x / 4.x</td>
19+
</tr>
20+
<tr>
21+
<td>2.x (<code>2.x</code> branch)</td>
22+
<td align="center">YES</td>
23+
<td align="center">YES, with <code><a href="https://socket.io/docs/v4/server-initialization/#allowEIO3">allowEIO3: true</a></code></td>
24+
</tr>
25+
<tr>
26+
<td>3.x (<code>master</code> branch)</td>
27+
<td align="center">NO</td>
28+
<td align="center">YES</td>
29+
</tr>
30+
</table>
31+
832
## Features
933

1034
- 100% written in modern C++11
11-
- Compatible with socket.io 1.0+ protocol
1235
- Binary support
1336
- Automatic JSON encoding
1437
- Multiplex support
1538
- Similar API to the Socket.IO JS client
1639
- Cross platform
1740

41+
Note: Only the WebSocket transport is currently implemented (no fallback to HTTP long-polling)
42+
1843
## Installation alternatives
1944

2045
* [With CMAKE](./INSTALL.md#with-cmake)

0 commit comments

Comments
 (0)