mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
更新ZLToolKit
This commit is contained in:
parent
b09919d374
commit
4d84661a87
@ -1 +1 @@
|
|||||||
Subproject commit f0608fb75660682150f45f857d5d8051880b13aa
|
Subproject commit fac78b63701ce6febd9ac6acefb637886c651873
|
@ -46,7 +46,7 @@ API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx,const char
|
|||||||
len = strlen(data);
|
len = strlen(data);
|
||||||
}
|
}
|
||||||
TcpSession *session = (TcpSession *)ctx;
|
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){
|
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](){
|
((TcpSession *)ctx)->async([weak_session,str](){
|
||||||
auto session_session = weak_session.lock();
|
auto session_session = weak_session.lock();
|
||||||
if(session_session){
|
if(session_session){
|
||||||
session_session->send(str);
|
session_session->SockSender::send(str);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}catch (std::exception &ex){
|
}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){
|
API_EXPORT void API_CALL mk_tcp_client_send(mk_tcp_client ctx, const char *data, int len){
|
||||||
assert(ctx && data);
|
assert(ctx && data);
|
||||||
TcpClient::Ptr *client = (TcpClient::Ptr *)ctx;
|
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){
|
API_EXPORT void API_CALL mk_tcp_client_send_safe(mk_tcp_client ctx, const char *data, int len){
|
||||||
|
@ -113,7 +113,7 @@ void HttpClient::onConnect(const SockException &ex) {
|
|||||||
printer << pr.first + ": ";
|
printer << pr.first + ": ";
|
||||||
printer << pr.second + "\r\n";
|
printer << pr.second + "\r\n";
|
||||||
}
|
}
|
||||||
send(printer << "\r\n");
|
SockSender::send(printer << "\r\n");
|
||||||
onFlush();
|
onFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@ void HttpSession::sendResponse(const char *pcStatus,
|
|||||||
str += "\r\n";
|
str += "\r\n";
|
||||||
}
|
}
|
||||||
str += "\r\n";
|
str += "\r\n";
|
||||||
send(std::move(str));
|
SockSender::send(std::move(str));
|
||||||
_ticker.resetTime();
|
_ticker.resetTime();
|
||||||
|
|
||||||
if(!size){
|
if(!size){
|
||||||
@ -611,7 +611,7 @@ void HttpSession::setSocketFlags(){
|
|||||||
//推流模式下,关闭TCP_NODELAY会增加推流端的延时,但是服务器性能将提高
|
//推流模式下,关闭TCP_NODELAY会增加推流端的延时,但是服务器性能将提高
|
||||||
SockUtil::setNoDelay(_sock->rawFD(), false);
|
SockUtil::setNoDelay(_sock->rawFD(), false);
|
||||||
//播放模式下,开启MSG_MORE会增加延时,但是能提高发送性能
|
//播放模式下,开启MSG_MORE会增加延时,但是能提高发送性能
|
||||||
(*this) << SocketFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE);
|
setSendFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
HttpWsClient(ClientTypeImp<ClientType,DataType> &delegate) : _delegate(delegate){
|
HttpWsClient(ClientTypeImp<ClientType,DataType> &delegate) : _delegate(delegate){
|
||||||
_Sec_WebSocket_Key = encodeBase64(SHA1::encode_bin(makeRandStr(16, false)));
|
_Sec_WebSocket_Key = encodeBase64(SHA1::encode_bin(makeRandStr(16, false)));
|
||||||
setPoller(delegate.getPoller());
|
_poller = delegate.getPoller();
|
||||||
}
|
}
|
||||||
~HttpWsClient(){}
|
~HttpWsClient(){}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ void RtmpPusher::setSocketFlags(){
|
|||||||
GET_CONFIG(bool,ultraLowDelay,General::kUltraLowDelay);
|
GET_CONFIG(bool,ultraLowDelay,General::kUltraLowDelay);
|
||||||
if(!ultraLowDelay) {
|
if(!ultraLowDelay) {
|
||||||
//提高发送性能
|
//提高发送性能
|
||||||
(*this) << SocketFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE);
|
setSendFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE);
|
||||||
SockUtil::setNoDelay(_sock->rawFD(), false);
|
SockUtil::setNoDelay(_sock->rawFD(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ void RtmpSession::setSocketFlags(){
|
|||||||
//推流模式下,关闭TCP_NODELAY会增加推流端的延时,但是服务器性能将提高
|
//推流模式下,关闭TCP_NODELAY会增加推流端的延时,但是服务器性能将提高
|
||||||
SockUtil::setNoDelay(_sock->rawFD(), false);
|
SockUtil::setNoDelay(_sock->rawFD(), false);
|
||||||
//播放模式下,开启MSG_MORE会增加延时,但是能提高发送性能
|
//播放模式下,开启MSG_MORE会增加延时,但是能提高发送性能
|
||||||
(*this) << SocketFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE);
|
setSendFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,7 +701,7 @@ void RtspPlayer::sendRtspRequest(const string &cmd, const string &url,const StrC
|
|||||||
for (auto &pr : header){
|
for (auto &pr : header){
|
||||||
printer << pr.first << ": " << pr.second << "\r\n";
|
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) {
|
void RtspPlayer::onRecvRTP_l(const RtpPacket::Ptr &pkt, const SdpTrack::Ptr &track) {
|
||||||
|
@ -395,7 +395,7 @@ void RtspPusher::setSocketFlags(){
|
|||||||
GET_CONFIG(bool,ultraLowDelay,General::kUltraLowDelay);
|
GET_CONFIG(bool,ultraLowDelay,General::kUltraLowDelay);
|
||||||
if(!ultraLowDelay) {
|
if(!ultraLowDelay) {
|
||||||
//提高发送性能
|
//提高发送性能
|
||||||
(*this) << SocketFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE);
|
setSendFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE);
|
||||||
SockUtil::setNoDelay(_sock->rawFD(), false);
|
SockUtil::setNoDelay(_sock->rawFD(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -471,7 +471,7 @@ void RtspPusher::sendRtspRequest(const string &cmd, const string &url,const StrC
|
|||||||
if(!sdp.empty()){
|
if(!sdp.empty()){
|
||||||
printer << sdp;
|
printer << sdp;
|
||||||
}
|
}
|
||||||
send(printer);
|
SockSender::send(printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1244,7 +1244,7 @@ void RtspSession::setSocketFlags(){
|
|||||||
//推流模式下,关闭TCP_NODELAY会增加推流端的延时,但是服务器性能将提高
|
//推流模式下,关闭TCP_NODELAY会增加推流端的延时,但是服务器性能将提高
|
||||||
SockUtil::setNoDelay(_sock->rawFD(), false);
|
SockUtil::setNoDelay(_sock->rawFD(), false);
|
||||||
//播放模式下,开启MSG_MORE会增加延时,但是能提高发送性能
|
//播放模式下,开启MSG_MORE会增加延时,但是能提高发送性能
|
||||||
(*this) << SocketFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE);
|
setSendFlags(SOCKET_DEFAULE_FLAGS | FLAG_MORE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ void ShellSession::onRecv(const Buffer::Ptr&buf) {
|
|||||||
_beatTicker.resetTime();
|
_beatTicker.resetTime();
|
||||||
_strRecvBuf.append(buf->data(), buf->size());
|
_strRecvBuf.append(buf->data(), buf->size());
|
||||||
if (_strRecvBuf.find("\xff\xf4\xff\0xfd\x06") != std::string::npos) {
|
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"));
|
shutdown(SockException(Err_other,"received Ctrl+C"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -78,20 +78,20 @@ inline bool ShellSession::onCommandLine(const string& line) {
|
|||||||
try {
|
try {
|
||||||
std::shared_ptr<stringstream> ss(new stringstream);
|
std::shared_ptr<stringstream> ss(new stringstream);
|
||||||
CMDRegister::Instance()(line,ss);
|
CMDRegister::Instance()(line,ss);
|
||||||
send(ss->str());
|
SockSender::send(ss->str());
|
||||||
}catch(ExitException &ex){
|
}catch(ExitException &ex){
|
||||||
return false;
|
return false;
|
||||||
}catch(std::exception &ex){
|
}catch(std::exception &ex){
|
||||||
send(ex.what());
|
SockSender::send(ex.what());
|
||||||
send("\r\n");
|
SockSender::send("\r\n");
|
||||||
}
|
}
|
||||||
printShellPrefix();
|
printShellPrefix();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ShellSession::pleaseInputUser() {
|
inline void ShellSession::pleaseInputUser() {
|
||||||
send("\033[0m");
|
SockSender::send("\033[0m");
|
||||||
send(StrPrinter << SERVER_NAME << " login: " << endl);
|
SockSender::send(StrPrinter << SERVER_NAME << " login: " << endl);
|
||||||
_loginInterceptor = [this](const string &user_name) {
|
_loginInterceptor = [this](const string &user_name) {
|
||||||
_strUserName=user_name;
|
_strUserName=user_name;
|
||||||
pleaseInputPasswd();
|
pleaseInputPasswd();
|
||||||
@ -99,24 +99,24 @@ inline void ShellSession::pleaseInputUser() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
inline void ShellSession::pleaseInputPasswd() {
|
inline void ShellSession::pleaseInputPasswd() {
|
||||||
send("Password: \033[8m");
|
SockSender::send("Password: \033[8m");
|
||||||
_loginInterceptor = [this](const string &passwd) {
|
_loginInterceptor = [this](const string &passwd) {
|
||||||
auto onAuth = [this](const string &errMessage){
|
auto onAuth = [this](const string &errMessage){
|
||||||
if(!errMessage.empty()){
|
if(!errMessage.empty()){
|
||||||
//鉴权失败
|
//鉴权失败
|
||||||
send(StrPrinter
|
SockSender::send(StrPrinter
|
||||||
<<"\033[0mAuth failed("
|
<< "\033[0mAuth failed("
|
||||||
<< errMessage
|
<< errMessage
|
||||||
<<"), please try again.\r\n"
|
<< "), please try again.\r\n"
|
||||||
<<_strUserName<<"@"<<SERVER_NAME
|
<< _strUserName << "@" << SERVER_NAME
|
||||||
<<"'s password: \033[8m"
|
<< "'s password: \033[8m"
|
||||||
<<endl);
|
<< endl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
send("\033[0m");
|
SockSender::send("\033[0m");
|
||||||
send("-----------------------------------------\r\n");
|
SockSender::send("-----------------------------------------\r\n");
|
||||||
send(StrPrinter<<"欢迎来到"<<SERVER_NAME<<", 你可输入\"help\"查看帮助.\r\n"<<endl);
|
SockSender::send(StrPrinter<<"欢迎来到"<<SERVER_NAME<<", 你可输入\"help\"查看帮助.\r\n"<<endl);
|
||||||
send("-----------------------------------------\r\n");
|
SockSender::send("-----------------------------------------\r\n");
|
||||||
printShellPrefix();
|
printShellPrefix();
|
||||||
_loginInterceptor=nullptr;
|
_loginInterceptor=nullptr;
|
||||||
};
|
};
|
||||||
@ -146,7 +146,7 @@ inline void ShellSession::pleaseInputPasswd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void ShellSession::printShellPrefix() {
|
inline void ShellSession::printShellPrefix() {
|
||||||
send(StrPrinter << _strUserName << "@" << SERVER_NAME << "# " << endl);
|
SockSender::send(StrPrinter << _strUserName << "@" << SERVER_NAME << "# " << endl);
|
||||||
}
|
}
|
||||||
|
|
||||||
}/* namespace mediakit */
|
}/* namespace mediakit */
|
||||||
|
@ -36,7 +36,7 @@ protected:
|
|||||||
}
|
}
|
||||||
//tcp连接成功后每2秒触发一次该事件
|
//tcp连接成功后每2秒触发一次该事件
|
||||||
void onManager() override {
|
void onManager() override {
|
||||||
send("echo test!");
|
SockSender::send("echo test!");
|
||||||
DebugL << "send echo test";
|
DebugL << "send echo test";
|
||||||
}
|
}
|
||||||
//连接服务器结果回调
|
//连接服务器结果回调
|
||||||
|
@ -35,7 +35,7 @@ public:
|
|||||||
}
|
}
|
||||||
void onRecv(const Buffer::Ptr &buffer) override {
|
void onRecv(const Buffer::Ptr &buffer) override {
|
||||||
//回显数据
|
//回显数据
|
||||||
send("from EchoSession:");
|
SockSender::send("from EchoSession:");
|
||||||
send(buffer);
|
send(buffer);
|
||||||
}
|
}
|
||||||
void onError(const SockException &err) override{
|
void onError(const SockException &err) override{
|
||||||
@ -62,7 +62,7 @@ public:
|
|||||||
}
|
}
|
||||||
void onRecv(const Buffer::Ptr &buffer) override {
|
void onRecv(const Buffer::Ptr &buffer) override {
|
||||||
//回显数据
|
//回显数据
|
||||||
send("from EchoSessionWithUrl:");
|
SockSender::send("from EchoSessionWithUrl:");
|
||||||
send(buffer);
|
send(buffer);
|
||||||
}
|
}
|
||||||
void onError(const SockException &err) override{
|
void onError(const SockException &err) override{
|
||||||
|
Loading…
Reference in New Issue
Block a user