Search Unity

NetworkMigrationManager with external LostConnectionCall

Discussion in 'Multiplayer' started by Lost-in-the-Garden, Apr 6, 2017.

  1. Lost-in-the-Garden

    Lost-in-the-Garden

    Joined:
    Nov 18, 2015
    Posts:
    176
    Hello!

    I am trying to establish a new Connection when the Host drops away. I get from my Platform the information to which new Host I should Connect. We are using pure Peer to peer connections. I am now inheriting from NetworkMigrationManager.

    All I do is Add is this method which I call as soon I get the new Information from the platform:

    Code (CSharp):
    1.  
    2.         public void HostChanged(bool isNewHost, System.Net.EndPoint newEndpoint)
    3.         {
    4.             Debug.Log("I have to change to a new Host!!");
    5.             if (isNewHost)
    6.             {
    7.                 Debug.Log("I am becomming the new Host!!");
    8.                 waitingToBecomeNewHost = true;
    9.                 LostHostOnClient(NetworkManager.singleton.client.connection);
    10.                 BecomeNewHost(5555);
    11.             }
    12.             else
    13.             {
    14.                 Debug.Log("I am switching to a new host!!");
    15.                 Reset(oldServerConnectionId);
    16.                 NetworkManager.singleton.secureTunnelEndpoint = newEndpoint;
    17.                 NetworkManager.singleton.client.ReconnectToNewHost(newEndpoint);
    18.             }
    19.         }
    But when this code is called on the new Server I get this error:
    How should this pice of code look correctly? Any hints from someone?

    Thanks!
    Matthias