Commit 21acda1e by xiongziliang

实现getIdentifier接口

parent f98546a6
Subproject commit bb2ba9005b0191f709897bf51e5bb719eac856bb Subproject commit cff0af9180984312035ab5972a47e6b632e0919f
...@@ -172,7 +172,7 @@ protected: ...@@ -172,7 +172,7 @@ protected:
} }
//这是个WebSocket会话而不是普通的Http会话 //这是个WebSocket会话而不是普通的Http会话
_firstPacket = false; _firstPacket = false;
_session = std::make_shared<SessionImp>(nullptr,_sock); _session = std::make_shared<SessionImp>(getIdentifier(),nullptr,_sock);
auto strongServer = _weakServer.lock(); auto strongServer = _weakServer.lock();
if(strongServer){ if(strongServer){
...@@ -253,7 +253,11 @@ private: ...@@ -253,7 +253,11 @@ private:
*/ */
class SessionImp : public SessionType{ class SessionImp : public SessionType{
public: public:
SessionImp(const std::shared_ptr<ThreadPool> &pTh, const Socket::Ptr &pSock) : SessionType(pTh,pSock){}; SessionImp(const string &identifier,
const std::shared_ptr<ThreadPool> &pTh,
const Socket::Ptr &pSock) :
_identifier(identifier),SessionType(pTh,pSock){}
~SessionImp(){} ~SessionImp(){}
/** /**
...@@ -285,14 +289,18 @@ private: ...@@ -285,14 +289,18 @@ private:
} }
return SessionType::send(buf); return SessionType::send(buf);
} }
string getIdentifier() const override{
return _identifier;
}
private: private:
onBeforeSendCB _beforeSendCB; onBeforeSendCB _beforeSendCB;
string _identifier;
}; };
private: private:
std::shared_ptr<SessionImp> _session;
string _remian_data;
bool _firstPacket = true; bool _firstPacket = true;
string _remian_data;
weak_ptr<TcpServer> _weakServer; weak_ptr<TcpServer> _weakServer;
std::shared_ptr<SessionImp> _session;
}; };
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论