From 21acda1e4200b352cf033e31f2e0ec0016ce0f50 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 27 Sep 2018 09:13:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0getIdentifier=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZLToolKit | 2 +- src/Http/HttpSession.h | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ZLToolKit b/ZLToolKit index bb2ba900..cff0af91 160000 --- a/ZLToolKit +++ b/ZLToolKit @@ -1 +1 @@ -Subproject commit bb2ba9005b0191f709897bf51e5bb719eac856bb +Subproject commit cff0af9180984312035ab5972a47e6b632e0919f diff --git a/src/Http/HttpSession.h b/src/Http/HttpSession.h index aeeabaaa..1fdd68a5 100644 --- a/src/Http/HttpSession.h +++ b/src/Http/HttpSession.h @@ -172,7 +172,7 @@ protected: } //这是个WebSocket会话而不是普通的Http会话 _firstPacket = false; - _session = std::make_shared(nullptr,_sock); + _session = std::make_shared(getIdentifier(),nullptr,_sock); auto strongServer = _weakServer.lock(); if(strongServer){ @@ -253,7 +253,11 @@ private: */ class SessionImp : public SessionType{ public: - SessionImp(const std::shared_ptr &pTh, const Socket::Ptr &pSock) : SessionType(pTh,pSock){}; + SessionImp(const string &identifier, + const std::shared_ptr &pTh, + const Socket::Ptr &pSock) : + _identifier(identifier),SessionType(pTh,pSock){} + ~SessionImp(){} /** @@ -285,14 +289,18 @@ private: } return SessionType::send(buf); } + string getIdentifier() const override{ + return _identifier; + } private: onBeforeSendCB _beforeSendCB; + string _identifier; }; private: - std::shared_ptr _session; - string _remian_data; bool _firstPacket = true; + string _remian_data; weak_ptr _weakServer; + std::shared_ptr _session; }; /**