Author Topic: Multiple Servers on LAN?  (Read 3913 times)

junjet

  • Guest
Multiple Servers on LAN?
« on: August 20, 2013, 12:01:29 PM »
Hi there,

I own a NGUI, TNet & Starlink and my question is about creating multiple servers from a LAN feature of TNet.
I'm sure this is possible but testing this out with Starlink running the game on 2 computers connected to the same LAN.

Whenever I create a server on 1 computer it works like a charm as it is automatically discovered and listed as a server on the other computer.

But when I tried to create another server on the other computer (now both computers are running as servers). The server list flickers to and from the names of both servers from both computers but only on the same row though it seems like its overwriting the button label of the first item on the server list when it should have listed 2 items showing the 2 server names.

This is important in the game i want because i want to allow multiple servers on the same LAN.

Help anyone?

Thanks,

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Multiple Servers on LAN?
« Reply #1 on: August 20, 2013, 01:36:19 PM »
Where does the list flicker? Is it in the Starlink UI kit? If that's the case, then there may be a bug with how servers get listed.

junjet

  • Guest
Re: Multiple Servers on LAN?
« Reply #2 on: August 20, 2013, 08:04:15 PM »
The bug happens on Starlink as well as on the Tnet example scenes each time you create more than 1 server from 2 or more instance of the game.

The server list only list 1 item instead of multiple items and somehow the button label of the lone item list supposed to show the server name "flickers" (from the lack of a better term) between the other server names created.

junjet

  • Guest
Re: Multiple Servers on LAN?
« Reply #3 on: August 21, 2013, 04:25:32 AM »
Hi Aren,

I'm a great fan. :)

I'm digging more into this right now and so far I found the source of the bug.

The udplobbyclient requests for the list of knownservers and will listen for a response from udplobbyserver.

In the case of 2 or more game instance each running their own lobbyserver and lobbyclient AND at least 2 of them created a server on their own instance.

Their respective lobbyserver will store only 1 knownserver but the lobbyclient will receive 2 or more response from all lobby servers telling the client that they only have 1 knownserver.

The lobby client tries to read from these response from each lobbyserver clearing the list each time & only rendering 1 knownserver instead of all the collected servers from all lobbyservers.

The file i'm referring to is on TNUpdLobbyClient.cs (line 115) and stepping into that function call on TNServerList.cs (line 194)

My solution is to merge all the known servers from all lobbyservers as they're all broadcasted and received by the lobbyclient but i figured I should share my findings with you first.

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Multiple Servers on LAN?
« Reply #4 on: August 21, 2013, 09:46:29 AM »
You should only have one lobby server active. It wouldn't be much of a lobby otherwise.

junjet

  • Guest
Re: Multiple Servers on LAN?
« Reply #5 on: August 21, 2013, 10:19:10 AM »
Why would you have a list of servers on the lobbyserver if you are only expecting 1 server on the lobby?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Multiple Servers on LAN?
« Reply #6 on: August 21, 2013, 10:50:57 AM »
One lobby server. Many game servers.

junjet

  • Guest
Re: Multiple Servers on LAN?
« Reply #7 on: August 21, 2013, 11:27:34 AM »
yeah I know that Aren, but on the starlink and o tnet examples. Out of the box running an instance of the app will run both lobby server and and lobby client for each instance. Ideally I can manually turn off the lobby server of the other instance once a first lobby server instance is already existing but I thought that should have been automatically facilitated by the tnet framework so its all wrapped up for non devs, right? I was able to dig into that and also from the conversation we have here made me realize as well and took me some time to figure out. I'm sure somebody out there must have had the same issues like mine.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Multiple Servers on LAN?
« Reply #8 on: August 21, 2013, 01:06:25 PM »
The examples, yes. When you host, it will also launch the discovery server. It's up to you to start only the servers you actually need.

grofie

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 17
    • View Profile
Re: Multiple Servers on LAN?
« Reply #9 on: December 09, 2013, 07:00:25 AM »
Hi ArenMook and junjettrasmonte,

I ran into the same problem and wanted to make sure you guys (especially junjettrasmonte) solved it similar  :

Its theoretically possible that our game runs with multiple servers in one lan, since each player can be a server.
The implementation is still quite basic, the join menu is not much more than the TNet example. I could not find the TNUdpLobbyServer script on any gameobject (so its hard to enable or disable the it), but the lobby still seams to work fine. I only got the previously described error with the lobby servers overwriting each-other.

I solved the problem by simply removing line 194 in TNServerList.cs ( list.Clear(); ). That way the list does not get cleared before receiving a new list from another lobby server so that multiple lobby servers are working.

I don't like this approach since I had to manipulate a TNet script, but I don't see any other way. The lobby servers are on only for a short time. When a second player joins, the game gets private immediately, the client can go offline any time so the lobby server would have to change. Since I have to choose to use a local or a remote lobby server on starting a game server (TNServerInstance.Start), it would mean I would have to restart a game server whenever the lobby server goes offline, besides the trouble of synchronizing the whole operation.

I hope I could make myself clear. Maybe you guys have a better approach for this problem and are willing to share it with me  ::) !?