mirror of
https://github.com/rustdesk/hbb_common.git
synced 2025-07-04 00:45:32 +00:00
[enhance] remove time ticking.
This commit is contained in:
parent
836dbbc144
commit
13ffda490d
@ -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…
x
Reference in New Issue
Block a user