Merge branch 'master' into master

This commit is contained in:
Joan Marcè i Igual 2022-02-25 09:13:57 +01:00 committed by GitHub
commit c7e4103dc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 104 additions and 18 deletions

40
CHANGELOG.md Normal file
View File

@ -0,0 +1,40 @@
# [2.1.0](https://github.com/socketio/socket.io-client-cpp/compare/2.0.0...2.1.0) (2021-10-12)
### Bug Fixes
* 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))
* 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))
### Features
* 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))
# [3.1.0](https://github.com/socketio/socket.io-client-cpp/compare/3.0.0...3.1.0) (2021-10-12)
### Bug Fixes
* lower the minimum CMake supported version ([b196fa7](https://github.com/socketio/socket.io-client-cpp/commit/b196fa7537cd3f7bed626ead873a7b71d1293c0d))
* handle closing sockets upon on_fail events ([d1c73b7](https://github.com/socketio/socket.io-client-cpp/commit/d1c73b73a8f536da3d353eac2a560af9791b13e3))
* resolve client_impl::ping LOG call syntax in debug builds ([e7de4eb](https://github.com/socketio/socket.io-client-cpp/commit/e7de4ebf64f4f49e18594a2c093c07beb963579a))
### Features
* 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))
* add support for logging configuration ([1b42ce7](https://github.com/socketio/socket.io-client-cpp/commit/1b42ce738f4c3e260f79bcb143bfe6efcdce5709))
* 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))
# [3.0.0](https://github.com/socketio/socket.io-client-cpp/compare/2.0.0...3.0.0) (2021-01-09)
### Features
* add support for Socket.IO v3 ([ec4d540](https://github.com/socketio/socket.io-client-cpp/commit/ec4d540ad54593604ac2091e67ffc2a6d9a00db6))

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
PROJECT(sioclient)
option(BUILD_SHARED_LIBS "Build the shared library" OFF)
@ -32,8 +32,9 @@ add_definitions(
)
add_library(sioclient ${ALL_SRC})
target_include_directories(sioclient PRIVATE
target_include_directories(sioclient PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include
@ -57,8 +58,9 @@ list(APPEND TARGET_LIBRARIES sioclient)
find_package(OpenSSL)
if(OPENSSL_FOUND)
add_library(sioclient_tls ${ALL_SRC})
target_include_directories(sioclient_tls PRIVATE
target_include_directories(sioclient_tls PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/lib/websocketpp
${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson/include
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include

View File

@ -12,3 +12,17 @@
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.
4. Add `BOOST_DATE_TIME_NO_LIB`, `BOOST_REGEX_NO_LIB`, `ASIO_STANDALONE`, `_WEBSOCKETPP_CPP11_STL_` and `_WEBSOCKETPP_CPP11_FUNCTIONAL_` to the preprocessor definitions
5. Include `sio_client.h` in your client code where you want to use it.
### With vcpkg
You can download and install the Socket.IO C++ client using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
```bash
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install socket-io-client
```
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.

View File

@ -44,6 +44,7 @@ Note: Only the WebSocket transport is currently implemented (no fallback to HTTP
* [With CMAKE](./INSTALL.md#with-cmake)
* [Without CMAKE](./INSTALL.md#without-cmake)
* [With VCPKG](./INSTALL.md#with-vcpkg)
* [iOS and OS X](./INSTALL_IOS.md)
* Option 1: Cocoapods
* Option 2: Create a static library

View File

@ -70,7 +70,7 @@ namespace sio
sync_close();
}
void client_impl::connect(const string& uri, const map<string,string>& query, const map<string, string>& headers)
void client_impl::connect(const string& uri, const map<string,string>& query, const map<string, string>& headers, const message::ptr& auth)
{
if(m_reconn_timer)
{
@ -108,6 +108,7 @@ namespace sio
m_query_string=move(query_str);
m_http_headers = headers;
m_auth = auth;
this->reset_states();
m_client.get_io_service().dispatch(std::bind(&client_impl::connect_impl,this,uri,m_query_string));
@ -140,7 +141,7 @@ namespace sio
}
else
{
pair<const string, socket::ptr> p(aux,shared_ptr<sio::socket>(new sio::socket(this,aux)));
pair<const string, socket::ptr> p(aux,shared_ptr<sio::socket>(new sio::socket(this,aux,m_auth)));
return (m_sockets.insert(p).first)->second;
}
}
@ -599,10 +600,12 @@ failed:
#if SIO_TLS
client_impl::context_ptr client_impl::on_tls_init(connection_hdl conn)
{
context_ptr ctx = context_ptr(new asio::ssl::context(asio::ssl::context::tlsv12));
context_ptr ctx = context_ptr(new asio::ssl::context(asio::ssl::context::tls));
asio::error_code ec;
ctx->set_options(asio::ssl::context::default_workarounds |
asio::ssl::context::single_dh_use,ec);
asio::ssl::context::no_tlsv1 |
asio::ssl::context::no_tlsv1_1 |
asio::ssl::context::single_dh_use,ec);
if(ec)
{
cerr<<"Init tls failed,reason:"<< ec.message()<<endl;

View File

@ -104,7 +104,7 @@ namespace sio
// Client Functions - such as send, etc.
void connect(const std::string& uri, const std::map<std::string, std::string>& queryString,
const std::map<std::string, std::string>& httpExtraHeaders);
const std::map<std::string, std::string>& httpExtraHeaders, const message::ptr& auth);
sio::socket::ptr const& socket(const std::string& nsp);
@ -199,6 +199,7 @@ namespace sio
std::string m_base_url;
std::string m_query_string;
std::map<std::string, std::string> m_http_headers;
message::ptr m_auth;
unsigned int m_ping_interval;
unsigned int m_ping_timeout;

View File

@ -69,18 +69,34 @@ namespace sio
void client::connect(const std::string& uri)
{
m_impl->connect(uri, {}, {});
m_impl->connect(uri, {}, {}, {});
}
void client::connect(const std::string& uri, const message::ptr& auth)
{
m_impl->connect(uri, {}, {}, auth);
}
void client::connect(const std::string& uri, const std::map<string,string>& query)
{
m_impl->connect(uri, query, {});
m_impl->connect(uri, query, {}, {});
}
void client::connect(const std::string& uri, const std::map<string,string>& query, const message::ptr& auth)
{
m_impl->connect(uri, query, {}, auth);
}
void client::connect(const std::string& uri, const std::map<std::string,std::string>& query,
const std::map<std::string,std::string>& http_extra_headers)
{
m_impl->connect(uri, query, http_extra_headers);
m_impl->connect(uri, query, http_extra_headers, {});
}
void client::connect(const std::string& uri, const std::map<std::string,std::string>& query,
const std::map<std::string,std::string>& http_extra_headers, const message::ptr& auth)
{
m_impl->connect(uri, query, http_extra_headers, auth);
}
socket::ptr const& client::socket(const std::string& nsp)

View File

@ -56,11 +56,18 @@ namespace sio
// Client Functions - such as send, etc.
void connect(const std::string& uri);
void connect(const std::string& uri, const message::ptr& auth);
void connect(const std::string& uri, const std::map<std::string,std::string>& query);
void connect(const std::string& uri, const std::map<std::string,std::string>& query, const message::ptr& auth);
void connect(const std::string& uri, const std::map<std::string,std::string>& query,
const std::map<std::string,std::string>& http_extra_headers);
void connect(const std::string& uri, const std::map<std::string,std::string>& query,
const std::map<std::string,std::string>& http_extra_headers, const message::ptr& auth);
void set_reconnect_attempts(int attempts);
void set_reconnect_delay(unsigned millis);

View File

@ -108,7 +108,7 @@ namespace sio
{
public:
impl(client_impl *,std::string const&);
impl(client_impl *, std::string const&, message::ptr const&);
~impl();
void on(std::string const& event_name,event_listener_aux const& func);
@ -173,6 +173,7 @@ namespace sio
bool m_connected;
std::string m_nsp;
message::ptr m_auth;
std::map<unsigned int, std::function<void (message::list const&)> > m_acks;
@ -228,10 +229,11 @@ namespace sio
m_error_listener = nullptr;
}
socket::impl::impl(client_impl *client,std::string const& nsp):
socket::impl::impl(client_impl *client, std::string const& nsp, message::ptr const& auth):
m_client(client),
m_connected(false),
m_nsp(nsp)
m_nsp(nsp),
m_auth(auth)
{
NULL_GUARD(client);
if(m_client->opened())
@ -269,7 +271,7 @@ namespace sio
void socket::impl::send_connect()
{
NULL_GUARD(m_client);
packet p(packet::type_connect,m_nsp);
packet p(packet::type_connect, m_nsp, m_auth);
m_client->send(p);
m_connection_timer.reset(new asio::steady_timer(m_client->get_io_service()));
asio::error_code ec;
@ -523,8 +525,8 @@ namespace sio
return socket::event_listener();
}
socket::socket(client_impl* client,std::string const& nsp):
m_impl(new impl(client,nsp))
socket::socket(client_impl* client,std::string const& nsp,message::ptr const& auth):
m_impl(new impl(client,nsp,auth))
{
}

View File

@ -75,7 +75,7 @@ namespace sio
std::string const& get_namespace() const;
protected:
socket(client_impl*,std::string const&);
socket(client_impl*,std::string const&,message::ptr const&);
void on_connected();