Skip to content

Commit

Permalink
debug 1111111
Browse files Browse the repository at this point in the history
  • Loading branch information
tkzcfc committed Jul 24, 2024
1 parent 9fadae8 commit 67465e4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion np_base/src/net/tcp_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::net::session_delegate::SessionDelegate;
use crate::net::WriterMessage;
use anyhow::anyhow;
use bytes::BytesMut;
use log::{error, info};
use log::{error, info, trace};
use std::net::SocketAddr;
use tokio::io::{
AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, BufWriter, ReadHalf, WriteHalf,
Expand Down Expand Up @@ -81,6 +81,7 @@ async fn poll_write<S>(
continue;
}

trace!("write data:{}", data.len());
if let Err(error) = writer.write_all(&data).await {
error!("[{addr}] error when write_all {:?}", error);
break;
Expand Down Expand Up @@ -120,6 +121,8 @@ where
return Err(anyhow!("[{addr}] socket closed."));
}

trace!("read data:{}", buffer.len());

// 循环解包
loop {
if buffer.is_empty() {
Expand All @@ -128,9 +131,11 @@ where
// 处理数据粘包
let result = delegate.on_try_extract_frame(&mut buffer)?;
if let Some(frame) = result {
trace!("read package");
// 收到完整消息
delegate.on_recv_frame(frame).await?;
} else {
trace!("read package........");
// 消息包接收还未完成
break;
}
Expand Down

0 comments on commit 67465e4

Please sign in to comment.