File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,11 @@ void socketio_client_handler::on_open(connection_ptr con)
42
42
{
43
43
m_con = con;
44
44
// Create the heartbeat timer and use the same io_service as the main event loop.
45
+ #ifndef BOOST_NO_CXX11_SMART_PTR
45
46
m_heartbeatTimer = std::unique_ptr<boost::asio::deadline_timer>(new boost::asio::deadline_timer (con->get_io_service (), boost::posix_time::seconds (0 )));
47
+ #else
48
+ m_heartbeatTimer = boost::shared_ptr<boost::asio::deadline_timer>(new boost::asio::deadline_timer (con->get_io_service (), boost::posix_time::seconds (0 )));
49
+ #endif
46
50
start_heartbeat ();
47
51
m_connected = true ;
48
52
Original file line number Diff line number Diff line change @@ -71,7 +71,13 @@ class socketio_client_handler : public client::handler {
71
71
// Function pointer to a event handler.
72
72
// Args is an array, managed by rapidjson, and could be null
73
73
// Can change to whatever signature you want, just make sure to change the call in on_socketio_event too.
74
+ #ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
75
+ // If you're using C++11 and have the proper functional header in the standard lib, we'll use that
74
76
typedef std::function<void (socketio_events&, const Value&)> eventFunc;
77
+ #else
78
+ // Otherwise we'll let boost fill in the gaps
79
+ typedef boost::function<void (socketio_events&, const Value&)> eventFunc;
80
+ #endif
75
81
76
82
// Performs a socket.IO handshake
77
83
// https://github.com/LearnBoost/socket.io-spec
@@ -152,7 +158,14 @@ class socketio_client_handler : public client::handler {
152
158
std::string m_transports;
153
159
154
160
// Heartbeat variabes.
161
+ #ifndef BOOST_NO_CXX11_SMART_PTR
162
+ // If you're using C++11 use the standar library smart pointer
155
163
std::unique_ptr<boost::asio::deadline_timer> m_heartbeatTimer;
164
+ #else
165
+ // Otherwise let boost provideo the smart pointer
166
+ boost::shared_ptr<boost::asio::deadline_timer> m_heartbeatTimer;
167
+ #endif
168
+
156
169
bool m_heartbeatActive;
157
170
158
171
// Event bindings
You can’t perform that action at this time.
0 commit comments