更新ZLToolKit

This commit is contained in:
xiongziliang 2020-04-23 17:50:12 +08:00
parent b09919d374
commit 4d84661a87
13 changed files with 36 additions and 36 deletions

@ -1 +1 @@
Subproject commit f0608fb75660682150f45f857d5d8051880b13aa
Subproject commit fac78b63701ce6febd9ac6acefb637886c651873

View File

@ -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){

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -73,7 +73,7 @@ public:
HttpWsClient(ClientTypeImp<ClientType,DataType> &delegate) : _delegate(delegate){
_Sec_WebSocket_Key = encodeBase64(SHA1::encode_bin(makeRandStr(16, false)));
setPoller(delegate.getPoller());
_poller = delegate.getPoller();
}
~HttpWsClient(){}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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<stringstream> 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<<"@"<<SERVER_NAME
<<"'s password: \033[8m"
<<endl);
SockSender::send(StrPrinter
<< "\033[0mAuth failed("
<< errMessage
<< "), please try again.\r\n"
<< _strUserName << "@" << SERVER_NAME
<< "'s password: \033[8m"
<< endl);
return;
}
send("\033[0m");
send("-----------------------------------------\r\n");
send(StrPrinter<<"欢迎来到"<<SERVER_NAME<<", 你可输入\"help\"查看帮助.\r\n"<<endl);
send("-----------------------------------------\r\n");
SockSender::send("\033[0m");
SockSender::send("-----------------------------------------\r\n");
SockSender::send(StrPrinter<<"欢迎来到"<<SERVER_NAME<<", 你可输入\"help\"查看帮助.\r\n"<<endl);
SockSender::send("-----------------------------------------\r\n");
printShellPrefix();
_loginInterceptor=nullptr;
};
@ -146,7 +146,7 @@ inline void ShellSession::pleaseInputPasswd() {
}
inline void ShellSession::printShellPrefix() {
send(StrPrinter << _strUserName << "@" << SERVER_NAME << "# " << endl);
SockSender::send(StrPrinter << _strUserName << "@" << SERVER_NAME << "# " << endl);
}
}/* namespace mediakit */

View File

@ -36,7 +36,7 @@ protected:
}
//tcp连接成功后每2秒触发一次该事件
void onManager() override {
send("echo test!");
SockSender::send("echo test!");
DebugL << "send echo test";
}
//连接服务器结果回调

View File

@ -35,7 +35,7 @@ public:
}
void onRecv(const Buffer::Ptr &buffer) override {
//回显数据
send("from EchoSession:");
SockSender::send("from EchoSession:");
send(buffer);
}
void onError(const SockException &err) override{
@ -62,7 +62,7 @@ public:
}
void onRecv(const Buffer::Ptr &buffer) override {
//回显数据
send("from EchoSessionWithUrl:");
SockSender::send("from EchoSessionWithUrl:");
send(buffer);
}
void onError(const SockException &err) override{