完成tcp服务器/客户端 c api

This commit is contained in:
xiongziliang
2019-12-26 21:22:19 +08:00
parent 56397628da
commit 11a7d1e6c4
10 changed files with 658 additions and 329 deletions

View File

@@ -348,21 +348,25 @@ public:
/**
* 重载startConnect方法
* 目的是替换TcpClient的连接服务器行为使之先完成WebSocket握手
* @param strUrl websocket服务器ip或域名
* @param host websocket服务器ip或域名
* @param iPort websocket服务器端口
* @param fTimeOutSec 超时时间
*/
void startConnect(const string &strUrl, uint16_t iPort, float fTimeOutSec = 3) override {
void startConnect(const string &host, uint16_t iPort, float fTimeOutSec = 3) override {
string ws_url;
if(useWSS){
//加密的ws
ws_url = StrPrinter << "wss://" + strUrl << ":" << iPort << "/" ;
ws_url = StrPrinter << "wss://" + host << ":" << iPort << "/" ;
}else{
//明文ws
ws_url = StrPrinter << "ws://" + strUrl << ":" << iPort << "/" ;
ws_url = StrPrinter << "ws://" + host << ":" << iPort << "/" ;
}
_wsClient->startWsClient(ws_url,fTimeOutSec);
}
void startWebSocket(const string &ws_url,float fTimeOutSec = 3){
_wsClient->startWsClient(ws_url,fTimeOutSec);
}
private:
typename HttpWsClient<ClientType,DataType>::Ptr _wsClient;
};