diff --git a/src/cpp/handler/handlerengine.cpp b/src/cpp/handler/handlerengine.cpp index 1571fa3e..37ec4374 100644 --- a/src/cpp/handler/handlerengine.cpp +++ b/src/cpp/handler/handlerengine.cpp @@ -1256,6 +1256,9 @@ class HandlerEngine::Private : public QObject Connection connectionsRefreshedConnection; Connection unsubscribedConnection; Connection reportedConnection; + Connection sendConnection; + Connection expConnection; + Connection errorConnection; Connection pullConnection; Connection controlValveConnection; Connection inSubValveConnection; @@ -2600,9 +2603,9 @@ class HandlerEngine::Private : public QObject if(!s) { s = new WsSession(this); - connect(s, &WsSession::send, this, &Private::wssession_send); - connect(s, &WsSession::expired, this, &Private::wssession_expired); - connect(s, &WsSession::error, this, &Private::wssession_error); + sendConnection = s->send.connect(boost::bind(&Private::wssession_send, this, boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3, s)); + expConnection = s->expired.connect(boost::bind(&Private::wssession_expired, this, s)); + errorConnection = s->error.connect(boost::bind(&Private::wssession_error, this, s)); s->cid = QString::fromUtf8(item.cid); s->ttl = item.ttl; s->requestData.uri = item.uri; @@ -3132,10 +3135,8 @@ private slots: writeRetryPacket(rp); } - void wssession_send(int reqId, const QByteArray &type, const QByteArray &message) + void wssession_send(int reqId, const QByteArray &type, const QByteArray &message, WsSession *s) { - WsSession *s = (WsSession *)sender(); - WsControlPacket::Item i; i.cid = s->cid.toUtf8(); i.requestId = QByteArray::number(reqId); @@ -3147,17 +3148,13 @@ private slots: writeWsControlItems(QList() << i); } - void wssession_expired() + void wssession_expired(WsSession *s) { - WsSession *s = (WsSession *)sender(); - removeWsSession(s); } - void wssession_error() + void wssession_error(WsSession *s) { - WsSession *s = (WsSession *)sender(); - log_debug("ws session %s control error", qPrintable(s->cid)); WsControlPacket::Item i; diff --git a/src/cpp/handler/wssession.cpp b/src/cpp/handler/wssession.cpp index 58653bb2..0fad0eb0 100644 --- a/src/cpp/handler/wssession.cpp +++ b/src/cpp/handler/wssession.cpp @@ -122,7 +122,7 @@ void WsSession::expireTimer_timeout() { log_debug("timing out ws session: %s", qPrintable(cid)); - emit expired(); + expired(); } void WsSession::delayedTimer_timeout() @@ -135,7 +135,7 @@ void WsSession::delayedTimer_timeout() pendingRequests[reqId] = QDateTime::currentMSecsSinceEpoch() + WSCONTROL_REQUEST_TIMEOUT; setupRequestTimer(); - emit send(reqId, delayedType, message); + send(reqId, delayedType, message); } void WsSession::requestTimer_timeout() @@ -144,5 +144,5 @@ void WsSession::requestTimer_timeout() pendingRequests.clear(); setupRequestTimer(); - emit error(); + error(); } diff --git a/src/cpp/handler/wssession.h b/src/cpp/handler/wssession.h index 79d898f9..8d1c737c 100644 --- a/src/cpp/handler/wssession.h +++ b/src/cpp/handler/wssession.h @@ -27,6 +27,10 @@ #include #include #include "packet/httprequestdata.h" +#include + +using Signal = boost::signals2::signal; +using Connection = boost::signals2::scoped_connection; class QTimer; @@ -64,10 +68,9 @@ class WsSession : public QObject void sendDelayed(const QByteArray &type, const QByteArray &message, int timeout); void ack(int reqId); -signals: - void send(int reqId, const QByteArray &type, const QByteArray &message); - void expired(); - void error(); + boost::signals2::signal send; + Signal expired; + Signal error; private: void setupRequestTimer();