Author Topic: TNServerInstance.MakePrivate();  (Read 3456 times)

Sivand12

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
TNServerInstance.MakePrivate();
« on: November 19, 2014, 12:01:54 AM »
Hi @all

How can a game server which is marked as private with TNServerInstance.MakePrivate being marked as public again?

Cheers

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNServerInstance.MakePrivate();
« Reply #1 on: November 19, 2014, 04:20:54 PM »
Once you mark it as private, it effectively stops listening for incoming connections. You can't make it public again without restarting it. Its ideal usage is to prevent people from joining when you know that you're going to be shutting down the server.

Leslie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 17
    • View Profile
Re: TNServerInstance.MakePrivate();
« Reply #2 on: December 06, 2014, 03:33:56 PM »
Would this also remove it from the Lobby or is there a command for doing that? Thinking here about removing the game server after an oppoent joined a match. In my game it is always 1vs1 so when someone joined I do not want the server listed any longer.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNServerInstance.MakePrivate();
« Reply #3 on: December 07, 2014, 12:36:44 AM »
It gets removed automatically.

Leslie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 17
    • View Profile
Re: TNServerInstance.MakePrivate();
« Reply #4 on: December 07, 2014, 03:09:13 AM »
I do not understand. When does this happen automatically?

This is what I do now but want to do it the correct way if this is wrong...

  1. protected void OnNetworkPlayerJoin(TNet.Player plr)
  2. {
  3.         if (isServer)
  4.         {
  5.                 BattlemassUI.Instance.ShowMessage("", "Opponent connected. Setting up match ...", BattlemassUI.Icon_Wait, true);
  6.  
  7.                 otherPlayer = plr;
  8.                 state = State.WaitingToStart;
  9.  
  10.                 // client connected, remove self from server list
  11.                 StopBroadcastingServer();
  12.  
  13.                 // send map data to client and wait for reply
  14.                 tno.Send((byte)RFCs.OnMatchData, otherPlayer, Map.Instance.EnodeMapData());
  15.         }
  16. }
  17.  
  18. private void StopBroadcastingServer()
  19. {
  20.         if (state == State.Broadcasting)
  21.         {
  22.                 state = State.None;
  23.                 TNManager.StopUDP();
  24.                 if (GameGlobal.Instance.sessionType == SessionType.Internet)
  25.                 {       // stop lobby link since this server is "full"
  26.                         TNServerInstance.game.lobbyLink.Stop();
  27.                 }
  28.         }
  29. }
  30.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNServerInstance.MakePrivate();
« Reply #5 on: December 09, 2014, 02:06:55 PM »
TNManager.StopUDP? Why are you calling that? All you need to do is stop the TCP lobby client (or UDP, whichever you're using) by disabling that monobehaviour.

Leslie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 17
    • View Profile
Re: TNServerInstance.MakePrivate();
« Reply #6 on: December 11, 2014, 01:56:21 AM »
The UDP is activated when I want to broadcast a LAN game. I call this one functions to handle both LAN and Internet based games. I could probably have done a "if (GameGlobal.Instance.sessionType == SessionType.LAN)" for the StopUDP, but meh.. it does not error out.

ok.. so "TNServerInstance.game.lobbyLink.Stop();" is the right way? Just wanted to confirm.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNServerInstance.MakePrivate();
« Reply #7 on: December 11, 2014, 09:27:06 AM »
No, just disable the client monobehaviour. It stops itself automatically. When you need it again, re-enable it.