remove:去除冗余。
This commit is contained in:
parent
b02f091f79
commit
154c670839
@ -198,9 +198,7 @@ void CClient::handle_frame(CFrameBuffer* buf)
|
||||
logger_->error("{} nullptr.", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
auto t = static_cast<FrameType>(buf->type_);
|
||||
switch (t) {
|
||||
switch (buf->type_) {
|
||||
case TYPE_GET_LIST: {
|
||||
task_list_.clear();
|
||||
std::string source(buf->data_, buf->len_);
|
||||
|
@ -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<std::mutex> lock(mutex_);
|
||||
buffer_.push(tmp_buf_.data(), length);
|
||||
auto* frame = CTransProtocal::parse(buffer_);
|
||||
if (frame) {
|
||||
|
@ -101,8 +101,7 @@ void CTcpServer::handle_frame()
|
||||
continue;
|
||||
}
|
||||
|
||||
FrameType t = static_cast<FrameType>(buf->type_);
|
||||
switch (t) {
|
||||
switch (buf->type_) {
|
||||
case TYPE_GET_LIST: {
|
||||
logger_->info("[{}] GetList.", buf->fid_);
|
||||
get_client_list(&buf);
|
||||
|
@ -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<FrameType>(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;
|
||||
@ -110,9 +109,3 @@ CFrameBuffer::~CFrameBuffer()
|
||||
delete[] data_;
|
||||
len_ = 0;
|
||||
}
|
||||
|
||||
SimpleBuffer::~SimpleBuffer()
|
||||
{
|
||||
delete[] data_;
|
||||
len_ = 0;
|
||||
}
|
||||
|
10
util/util.h
10
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<void(CFrameBuffer* buf)>;
|
||||
/*
|
||||
【 transm TCP 数据协议 】
|
||||
|
Loading…
x
Reference in New Issue
Block a user