Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: devomage on July 20, 2016, 09:36:19 PM

Title: Detect if LobbyServer goes online or offline
Post by: devomage on July 20, 2016, 09:36:19 PM
Detecting if a lobby server goes offline is available via checking the error string when TNLobbyClient.onChange fires...

How do you detect when the lobby server comes back online?  If the lobby server has 0 servers TNLobbyClient.onChange doesn't fire and 'errorString' remains "Unable to connect".

In this case:  I would expect onChange needs to fire and 'errorString' needs to be cleared.

Everything works fine if there are more than 0 servers connected to the lobby server... 

Edit:  errorString does not change from "Unable to connect" when 'list' changes from 0 to 1... not that it matters if list.size > 0 -- but still seems wonky that it's not cleared.

  1. Lobby Server Status:  online with 0 servers
  2.  
  3. >>> Pressing play:
  4.  
  5. TNLobbyClient.onChange:
  6. errorString = ""
  7. isActive = True
  8.  
  9. >>> Stop remote lobby server:
  10.  
  11. TNLobbyClient.onChange:
  12. errorString = "Unable to connect"
  13. isActive = True
  14.  
  15. >>> Start remote lobby server:
  16.  
  17. TNLobbyClient.onChange: (doesnt fire, vars remain unchanged)
  18. errorString = "Unable to connect"
  19. isActive = True
  20.  
Title: Re: Detect if LobbyServer goes online or offline
Post by: ArenMook on July 21, 2016, 12:09:34 PM
You can add errorString = ""; to TcpLobbyClient's Update function where it processes Disconnect and ResposneServerList packets.
  1.                                         else if (response == Packet.Disconnect)
  2.                                         {
  3.                                                 knownServers.Clear();
  4.                                                 isActive = false;
  5.                                                 changed = true;
  6.                                                 errorString = "";
  7.                                         }
  8.                                         else if (response == Packet.ResponseServerList)
  9.                                         {
  10.                                                 lock (knownServers.list) knownServers.list.Clear();
  11.                                                 knownServers.ReadFrom(reader, time);
  12.                                                 changed = true;
  13.                                                 errorString = "";
  14.                                         }
Title: Re: Detect if LobbyServer goes online or offline
Post by: devomage on July 24, 2016, 03:24:02 AM
This resolved the problem!