From a994e075b4adfc0b9cc10f7da12f93846ee67b21 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 5 May 2017 21:29:44 +0800 Subject: [PATCH] add test for telnet --- tests/test_server.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/test_server.cpp b/tests/test_server.cpp index 282730b5..eed2ef1d 100644 --- a/tests/test_server.cpp +++ b/tests/test_server.cpp @@ -25,12 +25,14 @@ #include "Poller/EventPoller.h" #include "Thread/WorkThreadPool.h" #include "Device/PlayerProxy.h" +#include "Shell/ShellSession.h" #include using namespace std; using namespace ZL::Util; using namespace ZL::Http; using namespace ZL::Rtsp; using namespace ZL::Rtmp; +using namespace ZL::Shell; using namespace ZL::Thread; using namespace ZL::Network; using namespace ZL::DEV; @@ -49,6 +51,15 @@ int main(int argc,char *argv[]){ map proxyMap; int i=0; for(auto url : urlList){ + //PlayerProxy构造函数前两个参数分别为应用名(app),流id(streamId) + //比如说应用为live,流id为0,那么直播地址为: + //http://127.0.0.1/live/0/hls.m3u8 + //rtsp://127.0.0.1/live/0 + //rtmp://127.0.0.1/live/0 + //录像地址为: + //http://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4 + //rtsp://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4 + //rtmp://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4 PlayerProxy::Ptr player(new PlayerProxy("live",std::to_string(i++).data())); player->play(url); proxyMap.emplace(string(url),player); @@ -67,23 +78,29 @@ int main(int argc,char *argv[]){ TcpServer::Ptr rtspSrv(new TcpServer()); TcpServer::Ptr rtmpSrv(new TcpServer()); TcpServer::Ptr httpSrv(new TcpServer()); + TcpServer::Ptr shellSrv(new TcpServer()); rtspSrv->start(mINI::Instance()[Config::Rtsp::kPort]); rtmpSrv->start(mINI::Instance()[Config::Rtmp::kPort]); httpSrv->start(mINI::Instance()[Config::Http::kPort]); + //简单的telnet服务器,可用于服务器调试,但是不能使用23端口 + //测试方法:telnet 127.0.0.1 8023 + //输入用户名和密码登录(user:test,pwd:123456),输入help命令查看帮助 + ShellSession::addUser("test","123456"); + shellSrv->start(8023); #ifdef ENABLE_OPENSSL TcpServer::Ptr httpsSrv(new TcpServer()); httpsSrv->start(mINI::Instance()[Config::Http::kSSLPort]); #endif //ENABLE_OPENSSL - EventPoller::Instance().runLoop(); - + proxyMap.clear(); rtspSrv.reset(); rtmpSrv.reset(); httpSrv.reset(); + shellSrv.reset(); #ifdef ENABLE_OPENSSL httpsSrv.reset();