Search Unity

[LLAPI] How to use 'ConnectWithSimulator'

Discussion in 'Multiplayer' started by Ghosthowl, Jun 17, 2015.

  1. Ghosthowl

    Ghosthowl

    Joined:
    Feb 2, 2014
    Posts:
    228
    I am trying to add latency simulation to it but I do not see any documentation as to how to set this up. I am trying to use ConnectWithSimulator.

    I do the following:

    Code (csharp):
    1.  
    2. socketId = NetworkTransport.AddHostWithSimulator(NetworkHostTopology, minTimeout, maxTimeout,
    3.   endPoint.Port);
    4. connectionId = NetworkTransport.ConnectWithSimulator(socketId, networkAddress, networkPort, 0, out error, simulatorConfig);
    5.  
    - but the error 'This host isn't configured to use simulator' pops up when trying this.
     
  2. sonnyg007

    sonnyg007

    Joined:
    May 10, 2015
    Posts:
    3
    Heya, I'm having the same problem. I've been trying different ways but I either get that same error or the unity editor simply crashes. Put in a bug report and using a delay buffer as a workaround.
     
  3. sonnyg007

    sonnyg007

    Joined:
    May 10, 2015
    Posts:
    3
    Tried to give this another shot today and was able to get it working. When adding the simulated host, the minTimeout parameter has to be <= than outMinDelay and inMinDelay set in the Simulator config. Here are the settings I'm using on the client side to get a simulated 150ms latency and 10% packet loss.

    Code (CSharp):
    1. HostTopology hostTopology = new HostTopology (cConfig, 1);
    2. //clientHostID = NetworkTransport.AddHost (hostTopology, 0);
    3. clientHostID = NetworkTransport.AddHostWithSimulator (hostTopology, 50, 200);
    4.        
    5. //ClientConnectionID = NetworkTransport.Connect (clientHostID, ip, port, 0, out error);
    6. ConnectionSimulatorConfig simConfig = new ConnectionSimulatorConfig (50, 75, 50, 75, 0.1f);
    7. ClientConnectionID = NetworkTransport.ConnectWithSimulator (clientHostID, ip, port, 0, out error, simConfig);
    8. connectionState = ClientConnectionState.Connecting;
    9. Debug.Log (string.Format ("ConnectionID: {0}. Connecting to server...", ClientConnectionID));
    Also setting minTimeout and maxTimeout to 0 will give a "This host isn't configured to use simulator" error when trying to connect.
     
    Last edited: Aug 29, 2015
    IgorAherne likes this.