Search Unity

GetRemoteDelayTimeMS host id out of bound

Discussion in 'Multiplayer' started by Saishy, Aug 5, 2017.

  1. Saishy

    Saishy

    Joined:
    Jun 3, 2010
    Posts:
    79
    I'm doing a simple message test, and put this code in my OnServerAddPlayer:

    Code (CSharp):
    1. public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) {
    2.         base.OnServerAddPlayer(conn, playerControllerId);
    3.  
    4.         //Initialize the time sync message
    5.         TimestampReceiveMessage timeMsg = new TimestampReceiveMessage();
    6.         timeMsg.serverTimeStamp = NetworkTransport.GetNetworkTimestamp();
    7.  
    8.         conn.Send(TimestampReceiveMessage.id, timeMsg);
    9.  
    10.         Debug.Log("OnServerAddPlayer");
    11.     }
    And this is supposed to receive it:

    Code (CSharp):
    1. //Used to create a sync time between clients
    2.     public void ReceiveTimeStamp(NetworkMessage msg) {
    3.         TimestampReceiveMessage message = msg.ReadMessage<TimestampReceiveMessage>();
    4.         byte error;
    5.         Debug.Log(NetworkTransport.GetRemoteDelayTimeMS(msg.conn.hostId, msg.conn.connectionId, message.serverTimeStamp, out error).ToString() + " MS Delay");
    6.     }
    But it seems that when the message is sent to itself (when the host is also a client) it gives me an error:
    host id out of bound id {-1} max id should be greater 0 and less than {1}.

    Is there any reason why? This does not happens to other clients connected to the host.
    If there is no way to fix, is there any way to detect the conn is to myself?

    Thanks in advance!
     
  2. Saishy

    Saishy

    Joined:
    Jun 3, 2010
    Posts:
    79
    Also, testing with far away friends it always return "0 ms delay".

    So I'm guessing it is also broken for now...
     
  3. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    HostId should be your own hostId AFAIK
     
  4. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476