no message

master
caiyuzheng 2021-03-20 00:12:39 +08:00
parent 99793e8db9
commit b08b85026e
3 changed files with 30 additions and 2 deletions

2
.gitignore vendored
View File

@ -7,3 +7,5 @@ build/
libd/
general/third/
general/CMakeFiles/
test/src/tcptest/third/
test/src/cpp11/third/

View File

@ -164,6 +164,7 @@ int TcpClientLibevent::ConnectServer() {
bufferevent_free(bev);
bev = nullptr;
printf("Connect failed\n");
return -1;
}
this->mStatus = TcpClientLibevent::CONNECTED;
return 0;

View File

@ -1,9 +1,34 @@
#include "TcpClient.h"
#include <iostream>
#include <atomic>
#include<chrono>
#include<thread>
extern "C"{
#include <time.h>
}
using namespace std;
class Observer: public TcpClientLibevent::TcpClientObserver {
void OnConnected() {
std::cout<<"connected";
}
virtual void OnDisConnected() {
}
virtual void OnData(uint8_t *dat,uint64_t len){
}
virtual void OnClose(){
}
};
int main(){
TcpClientLibevent mTcp("127.0.0.1",8443, nullptr);
Observer p ;
TcpClientLibevent mTcp("127.0.0.1",8443, &p);
while(true){
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}