Search Unity

Networking - get the current host

Discussion in 'Multiplayer' started by benblo, Oct 31, 2007.

  1. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    I can know that I'm connected to a host using Network.peerType or Network.isClient, but I couldn't find a way to get the HostData, like Network.host, or HostData.current... does it exist?
    If not, well, it should.
     
  2. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    280
    HostData objects are sent by the master server and thats separate from the Network Manager himself. You manually take the data from a HostData object, the IP and port, and use that in Network.Connect(). There is now way for Unity to know which HostData object from MasterServer.PollHostList you used when connecting.

    If you want to keep around the HostData object you should store the one you are using yourself.

    To get IP and port info on the current server the client is connected to you can use "Network.connections". On clients the only connection in that list is the one with the server.
     
  3. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    476
    That makes sense, thank you :) !