I’m doing a simple message test, and put this code in my OnServerAddPlayer:
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) {
base.OnServerAddPlayer(conn, playerControllerId);
//Initialize the time sync message
TimestampReceiveMessage timeMsg = new TimestampReceiveMessage();
timeMsg.serverTimeStamp = NetworkTransport.GetNetworkTimestamp();
conn.Send(TimestampReceiveMessage.id, timeMsg);
Debug.Log("OnServerAddPlayer");
}
And this is supposed to receive it:
//Used to create a sync time between clients
public void ReceiveTimeStamp(NetworkMessage msg) {
TimestampReceiveMessage message = msg.ReadMessage<TimestampReceiveMessage>();
byte error;
Debug.Log(NetworkTransport.GetRemoteDelayTimeMS(msg.conn.hostId, msg.conn.connectionId, message.serverTimeStamp, out error).ToString() + " MS Delay");
}
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!