mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed ping timeout logic
Former-commit-id: 080ca9d4149ec0ecddd92c475d77e4fc92f6edaa
This commit is contained in:
parent
ffc4e6ebd4
commit
8a0adab381
@ -217,10 +217,11 @@ impl Client {
|
|||||||
}
|
}
|
||||||
} else if let Some(err) = self.postbox.error() {
|
} else if let Some(err) = self.postbox.error() {
|
||||||
return Err(err.into());
|
return Err(err.into());
|
||||||
} else if self.state.get_time() - self.last_ping > SERVER_TIMEOUT * 0.5 {
|
|
||||||
self.postbox.send(ClientMsg::Ping);
|
|
||||||
} else if self.state.get_time() - self.last_ping > SERVER_TIMEOUT {
|
} else if self.state.get_time() - self.last_ping > SERVER_TIMEOUT {
|
||||||
return Err(Error::ServerTimeout);
|
return Err(Error::ServerTimeout);
|
||||||
|
} else if self.state.get_time() - self.last_ping > SERVER_TIMEOUT * 0.5 {
|
||||||
|
// Try pinging the server if the timeout is nearing
|
||||||
|
self.postbox.send(ClientMsg::Ping);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(frontend_events)
|
Ok(frontend_events)
|
||||||
|
@ -204,6 +204,9 @@ impl Server {
|
|||||||
client.postbox.error().is_some() // Postbox error
|
client.postbox.error().is_some() // Postbox error
|
||||||
{
|
{
|
||||||
disconnected = true;
|
disconnected = true;
|
||||||
|
} else if state.get_time() - client.last_ping > CLIENT_TIMEOUT * 0.5 {
|
||||||
|
// Try pinging the client if the timeout is nearing
|
||||||
|
client.postbox.send(ServerMsg::Ping);
|
||||||
}
|
}
|
||||||
|
|
||||||
if disconnected {
|
if disconnected {
|
||||||
|
Loading…
Reference in New Issue
Block a user