diff --git a/client/client.cpp b/client/client.cpp index fba65aa..87d4598 100644 --- a/client/client.cpp +++ b/client/client.cpp @@ -198,9 +198,7 @@ void CClient::handle_frame(CFrameBuffer* buf) logger_->error("{} nullptr.", __FUNCTION__); return; } - - auto t = static_cast(buf->type_); - switch (t) { + switch (buf->type_) { case TYPE_GET_LIST: { task_list_.clear(); std::string source(buf->data_, buf->len_); diff --git a/net/net_base.cpp b/net/net_base.cpp index 3d2b5be..87a4adb 100644 --- a/net/net_base.cpp +++ b/net/net_base.cpp @@ -60,11 +60,8 @@ void CTcpClient::async_recv() if (ec) { if (ec == asio::error::eof) { logger_->error("Remote Server Closed."); - return; } - async_recv(); } else { - std::lock_guard lock(mutex_); buffer_.push(tmp_buf_.data(), length); auto* frame = CTransProtocal::parse(buffer_); if (frame) { diff --git a/server/server.cpp b/server/server.cpp index 070275a..d7cd153 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -100,9 +100,8 @@ void CTcpServer::handle_frame() std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } - - FrameType t = static_cast(buf->type_); - switch (t) { + + switch (buf->type_) { case TYPE_GET_LIST: { logger_->info("[{}] GetList.", buf->fid_); get_client_list(&buf); diff --git a/util/util.cpp b/util/util.cpp index bddcd7e..87be4bb 100644 --- a/util/util.cpp +++ b/util/util.cpp @@ -65,7 +65,6 @@ CFrameBuffer* CTransProtocal::parse(CMutBuffer& buffer) result->tid_ = std::string(buffer.get_data() + find + 2 + 2 + 1 + 32); result->mark_ = mark; result->type_ = static_cast(type); - std::memset(result->data_, 0x0, len); std::memcpy(result->data_, buffer.get_data() + find + 2 + 2 + 1 + 4 + 32 + 32, len); buffer.remove_of(0, tail_index + 2); return result; @@ -109,10 +108,4 @@ CFrameBuffer::~CFrameBuffer() { delete[] data_; len_ = 0; -} - -SimpleBuffer::~SimpleBuffer() -{ - delete[] data_; - len_ = 0; -} +} \ No newline at end of file diff --git a/util/util.h b/util/util.h index e371f1a..b46832c 100644 --- a/util/util.h +++ b/util/util.h @@ -40,17 +40,7 @@ public: int len_{}; char mark_{}; }; -class SimpleBuffer -{ -public: - SimpleBuffer() = default; - ~SimpleBuffer(); -public: - std::string id_; - char* data_{}; - int len_{}; -}; using ExFun_t = std::function; /* 【 transm TCP 数据协议 】