Author Topic: How to wait for a host, or force a client to never be a host?  (Read 2958 times)

morty346

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
How to wait for a host, or force a client to never be a host?
« on: October 28, 2014, 08:11:29 AM »
I have a server client relationship where I require a specific entity to always be a server, and a client to always act like a client.  When I setup the client, and if he happens to connect before the server client to start up he becomes the host.

This also happens if my server starts, a client connects, the server dies, client stays searching, then server starts back up, and before the server can join the channel, my previous client connects and becomes the host

MCoburn

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 7
  • Posts: 69
    • View Profile
Re: How to wait for a host, or force a client to never be a host?
« Reply #1 on: October 29, 2014, 12:35:36 AM »
You could poll the amount of clients inside a channel. That way, the server client has to be in there. If channel user count = 0, then throw a "Waiting for server... X seconds remaining" box that clicks down, which ultimately says "Host did not appear inside the specified timeframe". There's other ways of doing this, but that's a quick and dirty way.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to wait for a host, or force a client to never be a host?
« Reply #2 on: October 29, 2014, 05:47:58 AM »
You can switch who's hosting using TNManager.SetHost.

morty346

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: How to wait for a host, or force a client to never be a host?
« Reply #3 on: November 04, 2014, 10:43:29 AM »
You could poll the amount of clients inside a channel. That way, the server client has to be in there. If channel user count = 0, then throw a "Waiting for server... X seconds remaining" box that clicks down, which ultimately says "Host did not appear inside the specified timeframe". There's other ways of doing this, but that's a quick and dirty way.

How do you poll a channel?

I see no functions that do this... other then connecting to a server, joining a server, then checking whats in there, then if not leaving channel, then trying it all over again...


morty346

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: How to wait for a host, or force a client to never be a host?
« Reply #4 on: November 04, 2014, 10:44:11 AM »
You can switch who's hosting using TNManager.SetHost.

I try this and it doesn't change the host ID - I get the correct ID of the host, then tell it to be set as host (from both the client and from the host I tried it) and nothing changes...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to wait for a host, or force a client to never be a host?
« Reply #5 on: November 04, 2014, 11:02:19 AM »
TNManager.players tells you who else is there. This list doesn't include your player.

SetHost will only work if called from the current host. You can debug it by putting Debug.Logs inside TNGameServer, around line 1347 (inside 'case Packet.RequestSetHost').