Skip to content

Commit c7e4103

Browse files
authored
Merge branch 'master' into master
2 parents 3ff5fc8 + d823428 commit c7e4103

File tree

10 files changed

+104
-18
lines changed

10 files changed

+104
-18
lines changed

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# [2.1.0](https://github.com/socketio/socket.io-client-cpp/compare/2.0.0...2.1.0) (2021-10-12)
2+
3+
4+
### Bug Fixes
5+
6+
* fix ASIO_STANDALONE release build trying to use boost::random ([#301](https://github.com/socketio/socket.io-client-cpp/issues/301)) ([168ce9d](https://github.com/socketio/socket.io-client-cpp/commit/168ce9d10b4ac667c43fe16b4cf530f6a3749235))
7+
* fix LOG call syntax ([#301](https://github.com/socketio/socket.io-client-cpp/issues/301)) ([c09221f](https://github.com/socketio/socket.io-client-cpp/commit/c09221f357effe1a5a0fc0e7d7902eba1ab0484d))
8+
9+
10+
### Features
11+
12+
* support TLSv1.2 and newer ([#321](https://github.com/socketio/socket.io-client-cpp/issues/321)) ([7c60ba9](https://github.com/socketio/socket.io-client-cpp/commit/7c60ba9d1e5e58de57f127025bcf69f4baecd2b4))
13+
14+
15+
16+
# [3.1.0](https://github.com/socketio/socket.io-client-cpp/compare/3.0.0...3.1.0) (2021-10-12)
17+
18+
19+
### Bug Fixes
20+
21+
* lower the minimum CMake supported version ([b196fa7](https://github.com/socketio/socket.io-client-cpp/commit/b196fa7537cd3f7bed626ead873a7b71d1293c0d))
22+
* handle closing sockets upon on_fail events ([d1c73b7](https://github.com/socketio/socket.io-client-cpp/commit/d1c73b73a8f536da3d353eac2a560af9791b13e3))
23+
* resolve client_impl::ping LOG call syntax in debug builds ([e7de4eb](https://github.com/socketio/socket.io-client-cpp/commit/e7de4ebf64f4f49e18594a2c093c07beb963579a))
24+
25+
26+
### Features
27+
28+
* allow resource path to be set in connection URI ([#134](https://github.com/socketio/socket.io-client-cpp/issues/134)) ([36a8cd4](https://github.com/socketio/socket.io-client-cpp/commit/36a8cd45272aa51f0f6ef27aa4744dbc6e8421f7))
29+
* add support for logging configuration ([1b42ce7](https://github.com/socketio/socket.io-client-cpp/commit/1b42ce738f4c3e260f79bcb143bfe6efcdce5709))
30+
* support TLSv1.2 and newer ([#321](https://github.com/socketio/socket.io-client-cpp/issues/321)) ([82d39a9](https://github.com/socketio/socket.io-client-cpp/commit/82d39a90ef118500a0329d214eec331db983bd74))
31+
32+
33+
34+
# [3.0.0](https://github.com/socketio/socket.io-client-cpp/compare/2.0.0...3.0.0) (2021-01-09)
35+
36+
37+
### Features
38+
39+
* add support for Socket.IO v3 ([ec4d540](https://github.com/socketio/socket.io-client-cpp/commit/ec4d540ad54593604ac2091e67ffc2a6d9a00db6))
40+

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
22
PROJECT(sioclient)
33

44
option(BUILD_SHARED_LIBS "Build the shared library" OFF)
@@ -32,8 +32,9 @@ add_definitions(
3232
)
3333

3434
add_library(sioclient ${ALL_SRC})
35-
target_include_directories(sioclient PRIVATE
35+
target_include_directories(sioclient PUBLIC
3636
${CMAKE_CURRENT_LIST_DIR}/src
37+
PRIVATE
3738
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
3839
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
3940
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include
@@ -57,8 +58,9 @@ list(APPEND TARGET_LIBRARIES sioclient)
5758
find_package(OpenSSL)
5859
if(OPENSSL_FOUND)
5960
add_library(sioclient_tls ${ALL_SRC})
60-
target_include_directories(sioclient_tls PRIVATE
61+
target_include_directories(sioclient_tls PUBLIC
6162
${CMAKE_CURRENT_LIST_DIR}/src
63+
PRIVATE
6264
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
6365
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
6466
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include

INSTALL.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,17 @@
1212
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.
1313
4. Add `BOOST_DATE_TIME_NO_LIB`, `BOOST_REGEX_NO_LIB`, `ASIO_STANDALONE`, `_WEBSOCKETPP_CPP11_STL_` and `_WEBSOCKETPP_CPP11_FUNCTIONAL_` to the preprocessor definitions
1414
5. Include `sio_client.h` in your client code where you want to use it.
15+
16+
### With vcpkg
17+
18+
You can download and install the Socket.IO C++ client using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
19+
20+
```bash
21+
git clone https://github.com/Microsoft/vcpkg.git
22+
cd vcpkg
23+
./bootstrap-vcpkg.sh
24+
./vcpkg integrate install
25+
vcpkg install socket-io-client
26+
```
27+
28+
The Socket.IO client port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Note: Only the WebSocket transport is currently implemented (no fallback to HTTP
4444

4545
* [With CMAKE](./INSTALL.md#with-cmake)
4646
* [Without CMAKE](./INSTALL.md#without-cmake)
47+
* [With VCPKG](./INSTALL.md#with-vcpkg)
4748
* [iOS and OS X](./INSTALL_IOS.md)
4849
* Option 1: Cocoapods
4950
* Option 2: Create a static library

src/internal/sio_client_impl.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace sio
7070
sync_close();
7171
}
7272

73-
void client_impl::connect(const string& uri, const map<string,string>& query, const map<string, string>& headers)
73+
void client_impl::connect(const string& uri, const map<string,string>& query, const map<string, string>& headers, const message::ptr& auth)
7474
{
7575
if(m_reconn_timer)
7676
{
@@ -108,6 +108,7 @@ namespace sio
108108
m_query_string=move(query_str);
109109

110110
m_http_headers = headers;
111+
m_auth = auth;
111112

112113
this->reset_states();
113114
m_client.get_io_service().dispatch(std::bind(&client_impl::connect_impl,this,uri,m_query_string));
@@ -140,7 +141,7 @@ namespace sio
140141
}
141142
else
142143
{
143-
pair<const string, socket::ptr> p(aux,shared_ptr<sio::socket>(new sio::socket(this,aux)));
144+
pair<const string, socket::ptr> p(aux,shared_ptr<sio::socket>(new sio::socket(this,aux,m_auth)));
144145
return (m_sockets.insert(p).first)->second;
145146
}
146147
}
@@ -599,10 +600,12 @@ namespace sio
599600
#if SIO_TLS
600601
client_impl::context_ptr client_impl::on_tls_init(connection_hdl conn)
601602
{
602-
context_ptr ctx = context_ptr(new asio::ssl::context(asio::ssl::context::tlsv12));
603+
context_ptr ctx = context_ptr(new asio::ssl::context(asio::ssl::context::tls));
603604
asio::error_code ec;
604605
ctx->set_options(asio::ssl::context::default_workarounds |
605-
asio::ssl::context::single_dh_use,ec);
606+
asio::ssl::context::no_tlsv1 |
607+
asio::ssl::context::no_tlsv1_1 |
608+
asio::ssl::context::single_dh_use,ec);
606609
if(ec)
607610
{
608611
cerr<<"Init tls failed,reason:"<< ec.message()<<endl;

src/internal/sio_client_impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ namespace sio
104104

105105
// Client Functions - such as send, etc.
106106
void connect(const std::string& uri, const std::map<std::string, std::string>& queryString,
107-
const std::map<std::string, std::string>& httpExtraHeaders);
107+
const std::map<std::string, std::string>& httpExtraHeaders, const message::ptr& auth);
108108

109109
sio::socket::ptr const& socket(const std::string& nsp);
110110

@@ -199,6 +199,7 @@ namespace sio
199199
std::string m_base_url;
200200
std::string m_query_string;
201201
std::map<std::string, std::string> m_http_headers;
202+
message::ptr m_auth;
202203

203204
unsigned int m_ping_interval;
204205
unsigned int m_ping_timeout;

src/sio_client.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,34 @@ namespace sio
6969

7070
void client::connect(const std::string& uri)
7171
{
72-
m_impl->connect(uri, {}, {});
72+
m_impl->connect(uri, {}, {}, {});
73+
}
74+
75+
void client::connect(const std::string& uri, const message::ptr& auth)
76+
{
77+
m_impl->connect(uri, {}, {}, auth);
7378
}
7479

7580
void client::connect(const std::string& uri, const std::map<string,string>& query)
7681
{
77-
m_impl->connect(uri, query, {});
82+
m_impl->connect(uri, query, {}, {});
83+
}
84+
85+
void client::connect(const std::string& uri, const std::map<string,string>& query, const message::ptr& auth)
86+
{
87+
m_impl->connect(uri, query, {}, auth);
7888
}
7989

8090
void client::connect(const std::string& uri, const std::map<std::string,std::string>& query,
8191
const std::map<std::string,std::string>& http_extra_headers)
8292
{
83-
m_impl->connect(uri, query, http_extra_headers);
93+
m_impl->connect(uri, query, http_extra_headers, {});
94+
}
95+
96+
void client::connect(const std::string& uri, const std::map<std::string,std::string>& query,
97+
const std::map<std::string,std::string>& http_extra_headers, const message::ptr& auth)
98+
{
99+
m_impl->connect(uri, query, http_extra_headers, auth);
84100
}
85101

86102
socket::ptr const& client::socket(const std::string& nsp)

src/sio_client.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,18 @@ namespace sio
5656
// Client Functions - such as send, etc.
5757
void connect(const std::string& uri);
5858

59+
void connect(const std::string& uri, const message::ptr& auth);
60+
5961
void connect(const std::string& uri, const std::map<std::string,std::string>& query);
6062

63+
void connect(const std::string& uri, const std::map<std::string,std::string>& query, const message::ptr& auth);
64+
6165
void connect(const std::string& uri, const std::map<std::string,std::string>& query,
6266
const std::map<std::string,std::string>& http_extra_headers);
6367

68+
void connect(const std::string& uri, const std::map<std::string,std::string>& query,
69+
const std::map<std::string,std::string>& http_extra_headers, const message::ptr& auth);
70+
6471
void set_reconnect_attempts(int attempts);
6572

6673
void set_reconnect_delay(unsigned millis);

src/sio_socket.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace sio
108108
{
109109
public:
110110

111-
impl(client_impl *,std::string const&);
111+
impl(client_impl *, std::string const&, message::ptr const&);
112112
~impl();
113113

114114
void on(std::string const& event_name,event_listener_aux const& func);
@@ -173,6 +173,7 @@ namespace sio
173173

174174
bool m_connected;
175175
std::string m_nsp;
176+
message::ptr m_auth;
176177

177178
std::map<unsigned int, std::function<void (message::list const&)> > m_acks;
178179

@@ -228,10 +229,11 @@ namespace sio
228229
m_error_listener = nullptr;
229230
}
230231

231-
socket::impl::impl(client_impl *client,std::string const& nsp):
232+
socket::impl::impl(client_impl *client, std::string const& nsp, message::ptr const& auth):
232233
m_client(client),
233234
m_connected(false),
234-
m_nsp(nsp)
235+
m_nsp(nsp),
236+
m_auth(auth)
235237
{
236238
NULL_GUARD(client);
237239
if(m_client->opened())
@@ -269,7 +271,7 @@ namespace sio
269271
void socket::impl::send_connect()
270272
{
271273
NULL_GUARD(m_client);
272-
packet p(packet::type_connect,m_nsp);
274+
packet p(packet::type_connect, m_nsp, m_auth);
273275
m_client->send(p);
274276
m_connection_timer.reset(new asio::steady_timer(m_client->get_io_service()));
275277
asio::error_code ec;
@@ -523,8 +525,8 @@ namespace sio
523525
return socket::event_listener();
524526
}
525527

526-
socket::socket(client_impl* client,std::string const& nsp):
527-
m_impl(new impl(client,nsp))
528+
socket::socket(client_impl* client,std::string const& nsp,message::ptr const& auth):
529+
m_impl(new impl(client,nsp,auth))
528530
{
529531
}
530532

src/sio_socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ namespace sio
7575
std::string const& get_namespace() const;
7676

7777
protected:
78-
socket(client_impl*,std::string const&);
78+
socket(client_impl*,std::string const&,message::ptr const&);
7979

8080
void on_connected();
8181

0 commit comments

Comments
 (0)