Author Topic: TNServer Use / Explanation  (Read 4263 times)

rxmarcus

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 62
    • View Profile
TNServer Use / Explanation
« on: June 06, 2017, 12:18:38 PM »
I'm having a hard time understanding what the TNServer.exe is used for. Is it to be able to host dedicated servers? Or is it's main use to be a master server that I could put on Amazon Web Services and have players register their games with it? Could someone people give me a rundown of what it is, how to do use it? I couldn't find any documentation about it.

Thanks

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: TNServer Use / Explanation
« Reply #1 on: June 06, 2017, 08:17:43 PM »
It can be a dedicated game server or a lobby server (master server).

Load up TNetTest/ServerMain.cs to see the commandline args you can pass it. These args modify the behaviour of the server.

Example to launch as a TCP lobby server on port 25565:
  1. start "TNet Test Lobby Server" "TNServer.exe" -name "Lobby_TestSrv" -tcpLobby 25565
  2.  
Example to launch as a game server on port 28001 and 28002, and auto-register with the above lobby server (hosted on same PC):
  1. start "TNet Test Server" "TNServer.exe" -name "Game_TestSrv" -tcp 28001 -udp 28002 -tcpLobby "127.0.0.1" "25565"
  2.  

rxmarcus

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 62
    • View Profile
Re: TNServer Use / Explanation
« Reply #2 on: June 07, 2017, 11:52:17 AM »
Thank you for the examples, I was able to get a Lobby server up and running and I'm able to register with it now.

I wanted to ask if its normal for the TNServer.exe to be posting to the command line every few seconds like you see in this attached image? It has the
  • so I'm concerned that I'm somehow registering a new server every few seconds?


Also could you give me more details about use TNServer as a Game Server in regards to what that means exactly? Does that mean it can run as a headless version of my Unity game? Sorry for the questions, trying to wrap my head around the options available to me.

rxmarcus

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 62
    • View Profile
Re: TNServer Use / Explanation
« Reply #3 on: June 07, 2017, 12:26:33 PM »
Also I can't figure out how to edit posts on this forum..... so hopefully my image works this time


rxmarcus

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 62
    • View Profile
Re: TNServer Use / Explanation
« Reply #4 on: June 07, 2017, 02:49:55 PM »
Also, even though my games are getting registered on my Lobby server, when using the TNTcpLobbyClient class on a GameObject and then checking the KnownServersList, I always receive a count of 0 even when I know there is an active registered game.

I don't receive any errors and I've made sure my ports are correct... Any ideas what I might be doing wrong?

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: TNServer Use / Explanation
« Reply #5 on: June 08, 2017, 05:13:22 AM »
The lobby is bugged. Supposed to have been fixed in the latest update, but I'm not sure. You can take a look at the source and fix it yourself or wait until ArenMook sees this thread and takes another look.

Also could you give me more details about use TNServer as a Game Server in regards to what that means exactly? Does that mean it can run as a headless version of my Unity game? Sorry for the questions, trying to wrap my head around the options available to me.

It isn't a headless version of your game, no, it's a server for your game to network things through. I recommend going through the tutorials stickied in this forum and playing around with the example scenes within the TNet package. The server won't ever have knowledge of your game (nor the physics engine), it's simply used to keep state and pass information from client to client. The standalone executable is functionally identical to the TNServerInstance.Start(...) that I assume you've been using - except that you can run it on any machine 24/7.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNServer Use / Explanation
« Reply #6 on: June 10, 2017, 06:46:38 AM »
I thought the lobby was fixed already? I'm attaching the latest TNServer executable just in case.

rxmarcus

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 62
    • View Profile
Re: TNServer Use / Explanation
« Reply #7 on: June 11, 2017, 01:06:44 PM »
So I downloaded that latest exe, and I'm noticing now a warning that is being thrown from TNTcpLobbyClient

Failed to read past end of stream.
UnityEngine.Debug:LogWarning(Object)
TNet.TNTcpLobbyClient:Update() (at Assets/TNet/Client/TNTcpLobbyClient.cs:107)

Any idea what is wrong here?

rxmarcus

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 62
    • View Profile
Re: TNServer Use / Explanation
« Reply #8 on: June 11, 2017, 09:24:15 PM »
I ended up realizing that I had added a property to TNServerList.cs as I wanted to display a mapName to the user. (Which apparently the lobby server didn't like)
I realized as well I instead can just pack everything I want into a string and split it with a character like |
Hopefully that helps someone else.

danfoo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 93
    • View Profile
Re: TNServer Use / Explanation
« Reply #9 on: July 08, 2017, 07:09:40 AM »
If you don't want a lobby per se, but rather just p2p multiplayer with one player acting as authoritative server, and players finding each other using steamworks functions, am I correct in assuming the Tnet server is not needed at all?
The authoritative player would start a local server, and his friends would simply connect to him?

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: TNServer Use / Explanation
« Reply #10 on: July 08, 2017, 05:32:28 PM »
A standalone TNet server wouldn't be needed in that case, no. You'd use TNServerInstance.Start(...) on whichever client you want the others to connect to.