transm/client/client.cpp

26 lines
530 B
C++

#include "client.h"
#include <iostream>
CClient::CClient(const std::shared_ptr<spdlog::logger>& logger) : logger_(logger)
{
client_ = std::make_shared<CTcpClient>(io_context_, logger_);
}
CClient::~CClient()
{
}
void CClient::run()
{
std::thread thread([this]() { io_context_.run(); });
char line[512]{};
while (std::cin.getline(line, 512)) {
if (std::strstr(line, "end")) {
break;
}
}
client_->disconnect();
thread.join();
logger_->info("{} exit.", __FUNCTION__);
}