Speed up connecting
This commit is contained in:
parent
c75e0e40c7
commit
30ef3ab779
@ -100,7 +100,9 @@ impl<T: std::fmt::Debug + Clone + Serialize + DeserializeOwned + Send + Sync + '
|
|||||||
|
|
||||||
if let Some(_) = &self.udp.socket {
|
if let Some(_) = &self.udp.socket {
|
||||||
for (addr, conn) in &mut self.connections {
|
for (addr, conn) in &mut self.connections {
|
||||||
let interval = if conn.last_sent_ping > conn.last_recv_pong {
|
let interval = if conn.last_sent_ping > conn.last_recv_pong
|
||||||
|
&& conn.state == ConnectionState::Connected
|
||||||
|
{
|
||||||
self.config.max_ping_interval
|
self.config.max_ping_interval
|
||||||
} else {
|
} else {
|
||||||
self.config.ping_interval
|
self.config.ping_interval
|
||||||
@ -309,6 +311,8 @@ impl<T: std::fmt::Debug + Clone + Serialize + DeserializeOwned + Send + Sync + '
|
|||||||
if conn.state == ConnectionState::ConnectingNearlyReady
|
if conn.state == ConnectionState::ConnectingNearlyReady
|
||||||
|| conn.state == ConnectionState::ReceivingConnection
|
|| conn.state == ConnectionState::ReceivingConnection
|
||||||
{
|
{
|
||||||
|
// Workaround to make the first ping after connecting to be instantaneous
|
||||||
|
conn.last_recv_pong = Instant::now();
|
||||||
conn.state = ConnectionState::Connected;
|
conn.state = ConnectionState::Connected;
|
||||||
messages.push(PeerMessage::NewConnection(conn.clone()));
|
messages.push(PeerMessage::NewConnection(conn.clone()));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user