XtremeKevinChow / lidgren-network-gen3

Automatically exported from code.google.com/p/lidgren-network-gen3
0 stars 0 forks source link

NetConnection doesn't update always m_visibleStatus #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/lidgren-network-gen3/source/browse/trunk/Lidgren.Networ
k/NetConnection.Handshake.cs#54

According to this line, m_visibleStatus is updated only if StatusChanged 
message is disabled and not always.

m_visibleStatus must be updated regardless if StatusChanged is enabled or not.

This issue prevents the following code to be correct:

var c = client.Connect(ip);

for (var i = 0; i < 10000; i += 1000)
  if (c.Status == NetConnectionStatus.Connected)
    return true;
  else // Wait
    Thread.Sleep(1000);

return false;

Original issue reported on code.google.com by NN1436401@gmail.com on 26 Jul 2010 at 9:57

GoogleCodeExporter commented 9 years ago
It's updated in NetPeer.ReadMessage() line 167 - but requires you to read the 
message, since the property is synced to the last read statuschanged message.
I'll change m_visibleStatus to internal and update it directly to make it 
easier to follow the code.

The code snippet should probably read and respond to messages while blocking.

Original comment by lidg...@gmail.com on 26 Jul 2010 at 10:24