From 4d84661a87f03592db95ebde8d7483a03da697e7 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 23 Apr 2020 17:50:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0ZLToolKit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- api/source/mk_tcp.cpp | 6 +++--- src/Http/HttpClient.cpp | 2 +- src/Http/HttpSession.cpp | 4 ++-- src/Http/WebSocketClient.h | 2 +- src/Rtmp/RtmpPusher.cpp | 2 +- src/Rtmp/RtmpSession.cpp | 2 +- src/Rtsp/RtspPlayer.cpp | 2 +- src/Rtsp/RtspPusher.cpp | 4 ++-- src/Rtsp/RtspSession.cpp | 2 +- src/Shell/ShellSession.cpp | 38 +++++++++++++++++++------------------- tests/test_wsClient.cpp | 2 +- tests/test_wsServer.cpp | 4 ++-- 13 files changed, 36 insertions(+), 36 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index f0608fb7..fac78b63 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit f0608fb75660682150f45f857d5d8051880b13aa +Subproject commit fac78b63701ce6febd9ac6acefb637886c651873 diff --git a/api/source/mk_tcp.cpp b/api/source/mk_tcp.cpp index ace6bd1d..a6347015 100644 --- a/api/source/mk_tcp.cpp +++ b/api/source/mk_tcp.cpp @@ -46,7 +46,7 @@ API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx,const char len = strlen(data); } TcpSession *session = (TcpSession *)ctx; - session->send(data,len); + session->SockSender::send(data,len); } API_EXPORT void API_CALL mk_tcp_session_send_safe(const mk_tcp_session ctx,const char *data,int len){ @@ -60,7 +60,7 @@ API_EXPORT void API_CALL mk_tcp_session_send_safe(const mk_tcp_session ctx,const ((TcpSession *)ctx)->async([weak_session,str](){ auto session_session = weak_session.lock(); if(session_session){ - session_session->send(str); + session_session->SockSender::send(str); } }); }catch (std::exception &ex){ @@ -226,7 +226,7 @@ API_EXPORT void API_CALL mk_tcp_client_connect(mk_tcp_client ctx, const char *ho API_EXPORT void API_CALL mk_tcp_client_send(mk_tcp_client ctx, const char *data, int len){ assert(ctx && data); TcpClient::Ptr *client = (TcpClient::Ptr *)ctx; - (*client)->send(data,len); + (*client)->SockSender::send(data,len); } API_EXPORT void API_CALL mk_tcp_client_send_safe(mk_tcp_client ctx, const char *data, int len){ diff --git a/src/Http/HttpClient.cpp b/src/Http/HttpClient.cpp index a1163a15..c2c22745 100644 --- a/src/Http/HttpClient.cpp +++ b/src/Http/HttpClient.cpp @@ -113,7 +113,7 @@ void HttpClient::onConnect(const SockException &ex) { printer << pr.first + ": "; printer << pr.second + "\r\n"; } - send(printer << "\r\n"); + SockSender::send(printer << "\r\n"); onFlush(); } diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 92cb886d..441894e8 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -456,7 +456,7 @@ void HttpSession::sendResponse(const char *pcStatus, str += "\r\n"; } str += "\r\n"; - send(std::move(str)); + SockSender::send(std::move(str)); _ticker.resetTime(); if(!size){ @@ -611,7 +611,7 @@ void HttpSession::setSocketFlags(){ //推流模式下,关闭TCP_NODELAY会增加推流端的延时,但是服务器性能将提高 SockUtil::setNoDelay(_sock->rawFD(), false); //播放模式下,开启MSG_MORE会增加延时,但是能提高发送性能 - (*this) << SocketFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE); + setSendFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE); } } diff --git a/src/Http/WebSocketClient.h b/src/Http/WebSocketClient.h index a26fdc38..36e67516 100644 --- a/src/Http/WebSocketClient.h +++ b/src/Http/WebSocketClient.h @@ -73,7 +73,7 @@ public: HttpWsClient(ClientTypeImp &delegate) : _delegate(delegate){ _Sec_WebSocket_Key = encodeBase64(SHA1::encode_bin(makeRandStr(16, false))); - setPoller(delegate.getPoller()); + _poller = delegate.getPoller(); } ~HttpWsClient(){} diff --git a/src/Rtmp/RtmpPusher.cpp b/src/Rtmp/RtmpPusher.cpp index e5de8e60..3722e23d 100644 --- a/src/Rtmp/RtmpPusher.cpp +++ b/src/Rtmp/RtmpPusher.cpp @@ -231,7 +231,7 @@ void RtmpPusher::setSocketFlags(){ GET_CONFIG(bool,ultraLowDelay,General::kUltraLowDelay); if(!ultraLowDelay) { //提高发送性能 - (*this) << SocketFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE); + setSendFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE); SockUtil::setNoDelay(_sock->rawFD(), false); } } diff --git a/src/Rtmp/RtmpSession.cpp b/src/Rtmp/RtmpSession.cpp index 8c9028fc..8e8ca0ed 100644 --- a/src/Rtmp/RtmpSession.cpp +++ b/src/Rtmp/RtmpSession.cpp @@ -536,7 +536,7 @@ void RtmpSession::setSocketFlags(){ //推流模式下,关闭TCP_NODELAY会增加推流端的延时,但是服务器性能将提高 SockUtil::setNoDelay(_sock->rawFD(), false); //播放模式下,开启MSG_MORE会增加延时,但是能提高发送性能 - (*this) << SocketFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE); + setSendFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE); } } diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 24f6d1f1..c3e67827 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -701,7 +701,7 @@ void RtspPlayer::sendRtspRequest(const string &cmd, const string &url,const StrC for (auto &pr : header){ printer << pr.first << ": " << pr.second << "\r\n"; } - send(printer << "\r\n"); + SockSender::send(printer << "\r\n"); } void RtspPlayer::onRecvRTP_l(const RtpPacket::Ptr &pkt, const SdpTrack::Ptr &track) { diff --git a/src/Rtsp/RtspPusher.cpp b/src/Rtsp/RtspPusher.cpp index 922a553f..5243be4c 100644 --- a/src/Rtsp/RtspPusher.cpp +++ b/src/Rtsp/RtspPusher.cpp @@ -395,7 +395,7 @@ void RtspPusher::setSocketFlags(){ GET_CONFIG(bool,ultraLowDelay,General::kUltraLowDelay); if(!ultraLowDelay) { //提高发送性能 - (*this) << SocketFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE); + setSendFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE); SockUtil::setNoDelay(_sock->rawFD(), false); } } @@ -471,7 +471,7 @@ void RtspPusher::sendRtspRequest(const string &cmd, const string &url,const StrC if(!sdp.empty()){ printer << sdp; } - send(printer); + SockSender::send(printer); } diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index 0e7f3213..c6ca0038 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -1244,7 +1244,7 @@ void RtspSession::setSocketFlags(){ //推流模式下,关闭TCP_NODELAY会增加推流端的延时,但是服务器性能将提高 SockUtil::setNoDelay(_sock->rawFD(), false); //播放模式下,开启MSG_MORE会增加延时,但是能提高发送性能 - (*this) << SocketFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE); + setSendFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE); } } diff --git a/src/Shell/ShellSession.cpp b/src/Shell/ShellSession.cpp index e7f29285..358eac06 100644 --- a/src/Shell/ShellSession.cpp +++ b/src/Shell/ShellSession.cpp @@ -41,7 +41,7 @@ void ShellSession::onRecv(const Buffer::Ptr&buf) { _beatTicker.resetTime(); _strRecvBuf.append(buf->data(), buf->size()); if (_strRecvBuf.find("\xff\xf4\xff\0xfd\x06") != std::string::npos) { - send("\033[0m\r\n Bye bye!\r\n"); + SockSender::send("\033[0m\r\n Bye bye!\r\n"); shutdown(SockException(Err_other,"received Ctrl+C")); return; } @@ -78,20 +78,20 @@ inline bool ShellSession::onCommandLine(const string& line) { try { std::shared_ptr ss(new stringstream); CMDRegister::Instance()(line,ss); - send(ss->str()); + SockSender::send(ss->str()); }catch(ExitException &ex){ return false; }catch(std::exception &ex){ - send(ex.what()); - send("\r\n"); + SockSender::send(ex.what()); + SockSender::send("\r\n"); } printShellPrefix(); return true; } inline void ShellSession::pleaseInputUser() { - send("\033[0m"); - send(StrPrinter << SERVER_NAME << " login: " << endl); + SockSender::send("\033[0m"); + SockSender::send(StrPrinter << SERVER_NAME << " login: " << endl); _loginInterceptor = [this](const string &user_name) { _strUserName=user_name; pleaseInputPasswd(); @@ -99,24 +99,24 @@ inline void ShellSession::pleaseInputUser() { }; } inline void ShellSession::pleaseInputPasswd() { - send("Password: \033[8m"); + SockSender::send("Password: \033[8m"); _loginInterceptor = [this](const string &passwd) { auto onAuth = [this](const string &errMessage){ if(!errMessage.empty()){ //鉴权失败 - send(StrPrinter - <<"\033[0mAuth failed(" - << errMessage - <<"), please try again.\r\n" - <<_strUserName<<"@"<