mirror of
https://github.com/GiriNeko/hbb_common.git
synced 2025-12-16 21:37:27 +00:00
[enhance] remove time ticking.
This commit is contained in:
parent
836dbbc144
commit
13ffda490d
1 changed files with 0 additions and 7 deletions
|
|
@ -29,8 +29,6 @@ pub struct WsFramedStream {
|
||||||
// read_buf: BytesMut,
|
// read_buf: BytesMut,
|
||||||
}
|
}
|
||||||
|
|
||||||
const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(3);
|
|
||||||
const HEARTBEAT_TIMEOUT: Duration = Duration::from_secs(10);
|
|
||||||
impl WsFramedStream {
|
impl WsFramedStream {
|
||||||
pub async fn new<T: AsRef<str>>(
|
pub async fn new<T: AsRef<str>>(
|
||||||
url: T,
|
url: T,
|
||||||
|
|
@ -180,7 +178,6 @@ impl WsFramedStream {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub async fn next(&mut self) -> Option<Result<BytesMut, Error>> {
|
pub async fn next(&mut self) -> Option<Result<BytesMut, Error>> {
|
||||||
log::debug!("Waiting for next message");
|
log::debug!("Waiting for next message");
|
||||||
let start = std::time::Instant::now();
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match self.stream.next().await {
|
match self.stream.next().await {
|
||||||
|
|
@ -242,10 +239,6 @@ impl WsFramedStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if start.elapsed() > HEARTBEAT_TIMEOUT {
|
|
||||||
log::warn!("No message received within heartbeat timeout");
|
|
||||||
return Some(Err(Error::new(ErrorKind::TimedOut, "Heartbeat timeout")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue