Author Topic: Communication with Lobby Server  (Read 4614 times)

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Communication with Lobby Server
« on: September 25, 2016, 11:51:59 AM »
Trying to get a centralized location for verification of players and storage of players.  For instance, saving/loading from the lobby server to play on different gameservers. 

I've read all over the forums that you need a custom Lobby Server, but I haven't seen much follow up or examples.

What would be your suggestion in loading/saving a player on a centralized Lobby to play on different Gameservers. I have a few servers spread out: US, Europe, and Asia. At the moment, in my games players grab/switch characters from the respective server they play on.  I am hoping to have the characters available across any server and never on the device.

Can you push me in the right direction?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Communication with Lobby Server
« Reply #1 on: September 25, 2016, 08:18:48 PM »
The lobby server can save and load files, and you can expand it to add player verification (login name / pass) support. You can change the lobby server's logic to only send the list of servers the player is eligible for as well -- if you wanted private or beta servers for example. Connect to the lobby, verify, download your player file. You can then connect to a game server from the lobby's list and set the player data to whatever was in the player file. When disconnecting, save the player's data as a file on the lobby server.

Lobby server's code can be found in TNTcpLobbyServer.cs. You would be adding new packet support to its ProcessPacket() function.

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Communication with Lobby Server
« Reply #2 on: September 25, 2016, 11:15:20 PM »
The lobby server can save and load files, and you can expand it to add player verification (login name / pass) support. You can change the lobby server's logic to only send the list of servers the player is eligible for as well -- if you wanted private or beta servers for example. Connect to the lobby, verify, download your player file. You can then connect to a game server from the lobby's list and set the player data to whatever was in the player file. When disconnecting, save the player's data as a file on the lobby server.

Lobby server's code can be found in TNTcpLobbyServer.cs. You would be adding new packet support to its ProcessPacket() function.

So, back to TNET fundamentals 101, when you say connect to the lobby, do you mean connect via TNGameserver or directly like you would connect to the gameserver?

Using one script and the latest TNET3:

  1. using UnityEngine;
  2. using TNet;
  3.  
  4. public class test : MonoBehaviour {
  5.  
  6.         public int lobbyPort = 5127;
  7.         public int serverTcpPort = 5128;
  8.         public string lobbyUrl;
  9.  
  10.         public bool connectLobby;
  11.         public bool startServer;
  12.  
  13.  
  14.         void Update () {
  15.                 if (connectLobby) {
  16.                         connectLobby = false;
  17.                         LobbyConnect ();
  18.                 }
  19.                 if (startServer) {
  20.                         startServer = false;
  21.                         ServerStart ();
  22.                 }
  23.         }
  24.  
  25.         void LobbyConnect() {
  26. //              TNManager.Connect (lobbyUrl, lobbyPort);                                                //doesnt connect to lobby
  27. //              TNManager.Connect (lobbyUrl + ":" + lobbyPort.ToString());              //doesnt connect to lobby
  28.                 TNManager.Connect (lobbyUrl + ":" + serverTcpPort.ToString());  //works connects to gameserver
  29.         }
  30.  
  31.         void ServerStart() {
  32.                 TNServerInstance.serverName = "My Server";
  33.                 //Doesn't work/show output without devomages changes
  34.                 TNServerInstance.Start(5128, 0, null, TNServerInstance.Type.Tcp, Tools.ResolveEndPoint(lobbyUrl + ":" + lobbyPort.ToString()));// "your.lobbyServer.com:5129"));       
  35.         }
  36. }

Also, a new copy with no changes has the same issues as in this thread while adding a gameserver to the lobby server. No output shows, but after following devomage comments it will show some output.

http://www.tasharen.com/forum/index.php?topic=14734.0

Hopefully, cmifwdll drops in. Will happily buy him a copy of TNET3 if he wants to jump in on these discussions  ;)

  1.                                
  2. if (reader.ReadUInt16() != GameServer.gameID) return false;
  3. Tools.Print("HERE"  + mTime);      //line 332
  4. tc.Set("lastSend", mTime);/code]
  5.  
  6.  

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: Communication with Lobby Server
« Reply #3 on: September 26, 2016, 12:05:18 AM »
i believe i got everything working as-is without commenting out that line.

iirc, it was related to tracking TNLobbyClient.errorString...

http://www.tasharen.com/forum/index.php?topic=14742.msg64367#msg64367

edit:  added code snippet

  1.  
  2. public enum WEPPN_LobbyServerStatus
  3. {
  4.     Unknown = 0,
  5.     Online = 1,
  6.     Offline = 2
  7. }
  8.  
  9. private void OnChange_List()
  10. {
  11.         List<ServerList.Entry> list = TNLobbyClient.knownServers.list;
  12.  
  13.         //Debug.Log("OnChange_List: " + TNLobbyClient.errorString + " " + list.size);
  14.  
  15.         isOnline = string.IsNullOrEmpty(TNLobbyClient.errorString) ? true : false;
  16.        
  17.         _errorString = TNLobbyClient.errorString;
  18.         _isActive = TNLobbyClient.isActive;
  19.        
  20.         for (int i = 0; i < list.size; ++i)
  21.         {
  22.                 ServerList.Entry ent = list[i];
  23.  
  24.                 if (string.IsNullOrEmpty(ent.name))
  25.                 {
  26.                         Debug.Log("continue");
  27.  
  28.                         continue;
  29.                 }
  30.  
  31.                 if (Exists(ent.name)) UpdateServer(ent);
  32.                 else AddServer(ent);
  33.         }
  34.  
  35.         //if the server was online and now it is not in the list - mark it offline
  36.         foreach (DataNode server in WEPPN.data.GetChild("servers").children)
  37.         {
  38.                 string server_name = server.GetChild<string>("name");
  39.                 WEPPN_LobbyServerStatus status = Status(server_name);
  40.  
  41.                 if (status != WEPPN_LobbyServerStatus.Online) continue;
  42.  
  43.                 //if im not on the list, then im offline
  44.                 bool found = list.ToArray().FirstOrDefault(i => i.name == server_name) != null;
  45.  
  46.                 if (!found) StatusChange(server_name, false, true);
  47.         }
  48. }
  49.  
  50.  
  51.  
« Last Edit: September 26, 2016, 12:19:18 AM by devomage »

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Communication with Lobby Server
« Reply #4 on: September 26, 2016, 04:23:00 AM »
i believe i got everything working as-is without commenting out that line.

iirc, it was related to tracking TNLobbyClient.errorString...

http://www.tasharen.com/forum/index.php?topic=14742.msg64367#msg64367

[/code]

On a new copy of TNet3, to get an output on the lobby server as this:

[2016/09/26 15:57:15] + My Server (0)

with :

  1.         void ServerStart() {
  2.                 TNServerInstance.serverName = "My Server";
  3.                 //Doesn't work/show output without devomages changes
  4.                 TNServerInstance.Start(5128, 0, null, TNServerInstance.Type.Tcp, Tools.ResolveEndPoint(lobbyUrl + ":" + lobbyPort.ToString()));// "your.lobbyServer.com:5129"));      
  5.         }



I needed to comment out the line mentioned in your other thread. Which I am guessing everyone with a new copy of TNet will have to as well.

Also, looking over your threads, so you are using

TNserver.exe -name "Lobby" -tcpLobby 5127

TNserver.exe -name "LobbyServerToConnect" -tcp 5128 -tcpLobby 192.168.1.1 5127

TNserver.exe -name "GameServer in US" -tcp 5128 -tcpLobby 192.168.1.1 5127

TNserver.exe -name "GameServer in Canada" -tcp 5128 -tcpLobby 192.168.1.1 5127

Is that right?   And then you can direct connect to "LobbyServerToConnect" to perform the centralized functionality Aren was talking about.



devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: Communication with Lobby Server
« Reply #5 on: September 26, 2016, 11:32:25 PM »
i went back to an older project and yes, i had the line commented out on the lobby server.  it was not necessary to fix the original list issue - but appears needed for the lobby server.

here's hoping aren's next project includes extensive lobby server functionality.   :-X

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Communication with Lobby Server
« Reply #6 on: September 27, 2016, 09:28:21 PM »
Comment out what line? I am not sure what you guys are referring to...

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: Communication with Lobby Server
« Reply #7 on: September 28, 2016, 05:45:06 PM »
Commenting out this line:
http://www.tasharen.com/forum/index.php?topic=14734.0

is required for the lobby server to display:
[2016/09/26 15:57:15] + My Server (0)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Communication with Lobby Server
« Reply #8 on: September 29, 2016, 04:20:53 AM »
Ah, just change
  1. tc.Set("lastSend", mTime);
to
  1. tc.Set("lastSend", 1);