Host Migration

No Any proper demo about host migration.

It didn’t work no ?

yeh , i use the network migration manager component but still it wont work.

We’re going to need more information to determine the problem. How are you using it? Are you simply attaching it? Or are you calling the functions? If so, can we see the code?

--------->>> yehh i just attach the script of network migration manager to my network lobby game object it is as below

using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.NetworkSystem;

public class Networkmigrationmanager : NetworkMigrationManager {

public static Networkmigrationmanager Instance;
private PeerInfoMessage m_NewHostInfo = new PeerInfoMessage();

private void Awake()
{
print(“Migration Awake call…”);
if(Instance == null) Instance = this;
}

public override bool FindNewHost (out PeerInfoMessage newHostInfo, out bool youAreNewHost)
{
print (“FindNewHost”);
return base.FindNewHost (out newHostInfo, out youAreNewHost);
}

protected override void OnAuthorityUpdated (GameObject go, int connectionId, bool authorityState)
{
base.OnAuthorityUpdated (go, connectionId, authorityState);
print (“OnAuthorityUpdated”);
}

protected override void OnClientDisconnectedFromHost (NetworkConnection conn, out SceneChangeOption sceneChange)
{
base.OnClientDisconnectedFromHost (conn, out sceneChange);
print (“OnClientDisconnectedFromHost”);
bool newhost;
FindNewHost(out m_NewHostInfo, out newhost);
print("New host :- " + newhost);

if (newhost)
{
print("You become a new host at port :- "+NetworkManager.singleton.networkPort);
BecomeNewHost(NetworkManager.singleton.networkPort);
}

else
{
Reset(this.oldServerConnectionId);
waitingReconnectToNewHost = true;
NetworkManager.singleton.networkAddress = m_NewHostInfo.address;
NetworkManager.singleton.client.ReconnectToNewHost(m_NewHostInfo.address, NetworkManager.singleton.networkPort);
print("You become a new client reconnect port -------> " + NetworkManager.singleton.networkPort);
print("new server ip :- " + m_NewHostInfo.address);
}
}

protected override void OnPeersUpdated (PeerListMessage peers)
{
base.OnPeersUpdated (peers);
}

protected override void OnServerHostShutdown ()
{
base.OnServerHostShutdown ();
}

protected override void OnServerReconnectObject (NetworkConnection newConnection, GameObject oldObject, int oldConnectionId)
{
base.OnServerReconnectObject (newConnection, oldObject, oldConnectionId);
ReconnectObjectForConnection(newConnection,oldObject,oldConnectionId);
}

protected override void OnServerReconnectPlayer (NetworkConnection newConnection, GameObject oldPlayer, int oldConnectionId, short playerControllerId)
{
base.OnServerReconnectPlayer (newConnection, oldPlayer, oldConnectionId, playerControllerId);
ReconnectPlayerForConnection(newConnection, oldPlayer, oldConnectionId, playerControllerId);
}

protected override void OnServerReconnectPlayer(NetworkConnection newConnection, GameObject oldPlayer, int oldConnectionId, short playerControllerId, NetworkReader extraMessageReader)
{
base.OnServerReconnectPlayer(newConnection, oldPlayer, oldConnectionId, playerControllerId, extraMessageReader);

}
}

-------------->>>> when server connect and host the game .
public override void OnServerConnect(NetworkConnection conn)
{
Networkmigrationmanager.Instance.SendPeerInfo();
}

-------------->>>>and when any client connect to the network
public override void OnStartClient(NetworkClient lobbyClient)
{
Networkmigrationmanager.Instance.Initialize(lobbyClient, matchInfo);
}

-------------->>>> and when server disconnect from the network i will call the statement as below .

public override void OnClientDisconnect(NetworkConnection conn)
{
Networkmigrationmanager.Instance.LostHostOnClient(conn);
}

this is what i have done till now… is any thing remain ?

Ok. I’ve done a fair amount of searching for a while now on this topic. Unfortunately the only answer I’ve been able to find is that host migration simply does not work for anything other than a direct connection (eg LAN).

Below is a link to a post by the former developer of HLAPI that relay support was on the roadmap. The post was made about one month before he left the company.

https://discussions.unity.com/t/608053/2

Below is a link where a different developer said it was still on the roadmap. This was a little over a year later.

https://discussions.unity.com/t/654641/10

Below is a link to the HLAPI Pro (someone is trying to fix the bugs in it followed by new features) thread where someone inquired about host migration relay server support and it’s clear based on the question that it’s still only direct connection.

https://discussions.unity.com/t/636221 page-11#post-3355428

Thank you for searching about this topic and give me a better response… Is their any other choice instead of unity networking to perform the functionality like host migration in mobile device ?

Photon has a limited form of host migration…

https://doc.photonengine.com/en-us/pun/current/gameplay/hostmigration

Other than that none of the high level APIs I’ve researched (eg Forge) have host migration.

Okay thanks again for suggation.