mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Improve Connection with threading and some kind of congestion control
This commit is contained in:
parent
b6fcbc5fba
commit
4b6138e69b
12 changed files with 1163 additions and 716 deletions
|
@ -246,7 +246,7 @@ void Client::connect(Address address)
|
|||
{
|
||||
DSTACK(__FUNCTION_NAME);
|
||||
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
|
||||
m_con.setTimeoutMs(0);
|
||||
m_con.SetTimeoutMs(0);
|
||||
m_con.Connect(address);
|
||||
}
|
||||
|
||||
|
@ -563,8 +563,8 @@ void Client::step(float dtime)
|
|||
counter = 0.0;
|
||||
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
|
||||
// connectedAndInitialized() is true, peer exists.
|
||||
con::Peer *peer = m_con.GetPeer(PEER_ID_SERVER);
|
||||
infostream<<"Client: avg_rtt="<<peer->avg_rtt<<std::endl;
|
||||
float avg_rtt = m_con.GetPeerAvgRTT(PEER_ID_SERVER);
|
||||
infostream<<"Client: avg_rtt="<<avg_rtt<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -709,14 +709,6 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
|||
return;
|
||||
}
|
||||
|
||||
con::Peer *peer;
|
||||
{
|
||||
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
|
||||
// All data is coming from the server
|
||||
// PeerNotFoundException is handled by caller.
|
||||
peer = m_con.GetPeer(PEER_ID_SERVER);
|
||||
}
|
||||
|
||||
u8 ser_version = m_server_ser_ver;
|
||||
|
||||
//infostream<<"Client received command="<<(int)command<<std::endl;
|
||||
|
@ -2168,9 +2160,10 @@ ClientEvent Client::getClientEvent()
|
|||
|
||||
float Client::getRTT(void)
|
||||
{
|
||||
con::Peer *peer = m_con.GetPeerNoEx(PEER_ID_SERVER);
|
||||
if(!peer)
|
||||
return 0.0;
|
||||
return peer->avg_rtt;
|
||||
try{
|
||||
return m_con.GetPeerAvgRTT(PEER_ID_SERVER);
|
||||
} catch(con::PeerNotFoundException &e){
|
||||
return 1337;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue