diff --git a/API.md b/API.md
index 1061fc74..f1280eb4 100644
--- a/API.md
+++ b/API.md
@@ -168,6 +168,19 @@ Set listener for reconnecting is in process.
Set listener for reconnecting event, called once a delayed connecting is scheduled.
+#### Logs
+`void set_logs_default()`
+
+Configure logs to the default level (connect, disconnect, app)
+
+`void set_logs_quiet()`
+
+Configure logs to the quiet level
+
+`void set_logs_verbose()`
+
+Configure logs to the verbose level
+
#### Namespace
`socket::ptr socket(std::string const& nsp)`
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..286b43b1
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,25 @@
+# [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))
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 19c5e54d..f0bd6957 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
+cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
PROJECT(sioclient)
option(BUILD_SHARED_LIBS "Build the shared library" OFF)
@@ -39,9 +39,12 @@ target_include_directories(sioclient PRIVATE
${CMAKE_CURRENT_LIST_DIR}/lib/asio/asio/include
)
+if (CMAKE_VERSION VERSION_GREATER "3.1")
set_property(TARGET sioclient PROPERTY CXX_STANDARD 11)
set_property(TARGET sioclient PROPERTY CXX_STANDARD_REQUIRED ON)
-
+else()
+set_property(TARGET sioclient APPEND_STRING PROPERTY COMPILE_FLAGS "-std=c++11")
+endif()
if(BUILD_SHARED_LIBS)
set_target_properties(sioclient
PROPERTIES
@@ -62,9 +65,13 @@ target_include_directories(sioclient_tls PRIVATE
${OPENSSL_INCLUDE_DIR}
)
+if (CMAKE_VERSION VERSION_GREATER "3.1")
set_property(TARGET sioclient_tls PROPERTY CXX_STANDARD 11)
set_property(TARGET sioclient_tls PROPERTY CXX_STANDARD_REQUIRED ON)
target_link_libraries(sioclient_tls PRIVATE ${OPENSSL_LIBRARIES} )
+else()
+set_property(TARGET sioclient_tls APPEND_STRING PROPERTY COMPILE_FLAGS "-std=c++11")
+endif()
target_compile_definitions(sioclient_tls PRIVATE -DSIO_TLS)
if(BUILD_SHARED_LIBS)
set_target_properties(sioclient_tls
diff --git a/README.md b/README.md
index 46c9e5ed..5a68967f 100755
--- a/README.md
+++ b/README.md
@@ -8,10 +8,26 @@ By virtue of being written in C++, this client works in several different platfo
## Compatibility table
-| C++ Client version | Socket.IO server version |
-| ------------------- | ------------------------ |
-| 2.x (`2.x` branch) | 1.x / 2.x |
-| 3.x (master branch) | 3.x |
+
+
+ C++ Client version |
+ Socket.IO server version |
+
+
+ 1.x / 2.x |
+ 3.x / 4.x |
+
+
+ 2.x (2.x branch) |
+ YES |
+ YES, with allowEIO3: true |
+
+
+ 3.x (master branch) |
+ NO |
+ YES |
+
+
## Features
diff --git a/examples/QT/README.md b/examples/QT/README.md
index 03ccb8ec..f39c4052 100644
--- a/examples/QT/README.md
+++ b/examples/QT/README.md
@@ -2,7 +2,7 @@
In this tutorial we’ll learn how to create a QT chat application that communicates with a [Socket.IO Node.JS chat server](https://github.com/Automattic/socket.io/tree/master/examples/chat).
-###Introduction
+### Introduction
To follow along, start by cloning the repository: [socket.io-client-cpp](https://github.com/socketio/socket.io-client-cpp).
Using:
@@ -39,7 +39,7 @@ SioChatDemo
|__mainwindow.ui
```
-###Import SioClient and config compile options.
+### Import SioClient and config compile options.
Let's copy the SioClient into the QT project as a subfolder `sioclient`.
Edit `SioChatDemo.pro` to config paths and compile options, simply add:
@@ -82,7 +82,7 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L`our Win32 boost static lib f
else:unix: LIBS += -L`our osx boost static lib folder` -lboost
```
-###Make up mainwindow ui.
+### Make up mainwindow ui.
Make up a simple ui by drag and drop widget from `Widget box` in left side.
We finally end up with this:
@@ -101,7 +101,7 @@ It contains:
* a `QPushButton` at the bottomright for sending message, named `sendBtn`
-###Add Slots in mainwindow
+### Add Slots in mainwindow
Slots need to be added in `mainwindow` class to handle UI events.They are
* click login button
@@ -122,7 +122,7 @@ public Q_SLOTS:
void OnMessageReturn();
```
-###Connect UI event signal and slots together
+### Connect UI event signal and slots together
Open `mainwindow.ui` in Design mode. switch to `signals/slots` mode by check `Menu->Edit->Edit Signals/Slots`
By press left mouse on widget and drag on to the window (cursor will become a sign of electrical ground), to open the connection editor.
@@ -135,7 +135,7 @@ We finally end up with this:

-###Adding UI refresh Signals/Slots
+### Adding UI refresh Signals/Slots
`sio::client`'s callbacks are not in UI thread. However, UI is required to be updated by those callbacks, so we need some `Signal` for non-UI thread to "request" `Slots` functions been called in UI thread. Say if we want to signal `QListWidgetItem` being added, add:
```C++
@@ -160,7 +160,7 @@ Then connect them in `MainWindow` constructor.
connect(this,SIGNAL(RequestAddListItem(QListWidgetItem*)),this,SLOT(AddListItem(QListWidgetItem*)));
```
-###Init sio::client in MainWindow
+### Init sio::client in MainWindow
For single window applications, simply let `MainWindow` class holding the `sio::client` object:
declare a `unique_ptr` member of `sio::client` and Several event handling functions in `mainwindow.h`
@@ -214,7 +214,7 @@ MainWindow::MainWindow(QWidget *parent) :
}
```
-###Managing connection state
+### Managing connection state
We have several connection listeners for connection events.
First we want to send login message once we're connected, get the default `socket` from `client` to do that.
@@ -256,7 +256,7 @@ MainWindow::~MainWindow()
}
```
-###Handle socket.io events
+### Handle socket.io events
We'll need to handle socket.io events in our functions bind to socket.io events.
For example, we need to show received messages to the `listView`
@@ -278,7 +278,7 @@ void MainWindow::OnNewMessage(std::string const& name,message::ptr const& data,b
}
```
-###Sending chat message
+### Sending chat message
When `sendBtn` is clicked, we need to send the text in `messageEdit` to chatroom.
Add code to `SendBtnClicked()`:
@@ -301,7 +301,7 @@ void MainWindow::SendBtnClicked()
}
```
-###Further reading
+### Further reading
You can run [Demo project](https://github.com/socketio/socket.io-client-cpp/tree/master/examples/QT/SioChatDemo) to have a closer look.
Before running, please follow the [instructions](../../README.md#with_cmake) to make the sioclient library.
diff --git a/src/internal/sio_client_impl.cpp b/src/internal/sio_client_impl.cpp
index f78aea49..53cfe539 100644
--- a/src/internal/sio_client_impl.cpp
+++ b/src/internal/sio_client_impl.cpp
@@ -164,6 +164,22 @@ namespace sio
}
}
+ void client_impl::set_logs_default()
+ {
+ m_client.clear_access_channels(websocketpp::log::alevel::all);
+ m_client.set_access_channels(websocketpp::log::alevel::connect | websocketpp::log::alevel::disconnect | websocketpp::log::alevel::app);
+ }
+
+ void client_impl::set_logs_quiet()
+ {
+ m_client.clear_access_channels(websocketpp::log::alevel::all);
+ }
+
+ void client_impl::set_logs_verbose()
+ {
+ m_client.set_access_channels(websocketpp::log::alevel::all);
+ }
+
/*************************protected:*************************/
void client_impl::send(packet& p)
{
@@ -222,7 +238,12 @@ namespace sio
} else {
ss<0){
ss<<"&sid="<close();
+ return;
+ }
+
m_con.reset();
m_con_state = con_closed;
this->sockets_invoke_void(&sio::socket::on_disconnect);
@@ -388,6 +415,12 @@ namespace sio
void client_impl::on_open(connection_hdl con)
{
+ if (m_con_state == con_closing) {
+ LOG("Connection opened while closing." << endl);
+ this->close();
+ return;
+ }
+
LOG("Connected." << endl);
m_con_state = con_opened;
m_con = con;
@@ -566,11 +599,12 @@ namespace sio
#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::tlsv1));
+ 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::no_sslv2 |
- 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()<millis) m_reconn_delay = millis;}
-
+
+ void set_logs_default();
+
+ void set_logs_quiet();
+
+ void set_logs_verbose();
+
protected:
void send(packet& p);
diff --git a/src/sio_client.cpp b/src/sio_client.cpp
index d85f7bfe..b475e6f7 100644
--- a/src/sio_client.cpp
+++ b/src/sio_client.cpp
@@ -123,5 +123,20 @@ namespace sio
{
m_impl->set_reconnect_delay_max(millis);
}
-
+
+ void client::set_logs_default()
+ {
+ m_impl->set_logs_default();
+ }
+
+ void client::set_logs_quiet()
+ {
+ m_impl->set_logs_quiet();
+ }
+
+ void client::set_logs_verbose()
+ {
+ m_impl->set_logs_verbose();
+ }
+
}
diff --git a/src/sio_client.h b/src/sio_client.h
index 77be0a2d..c37882ab 100644
--- a/src/sio_client.h
+++ b/src/sio_client.h
@@ -66,7 +66,13 @@ namespace sio
void set_reconnect_delay(unsigned millis);
void set_reconnect_delay_max(unsigned millis);
-
+
+ void set_logs_default();
+
+ void set_logs_quiet();
+
+ void set_logs_verbose();
+
sio::socket::ptr const& socket(const std::string& nsp = "");
// Closes the connection