internal NetworkClient BecomeHostInternal(NetworkClient oldClient, int port, MatchInfo matchInfo, int oldConnectionId, PeerInfoMessage[] peers)
{
if (s_Active)
{
if (LogFilter.logError)
{
Debug.LogError("BecomeHost already a server.");
}
return null;
}
if (!NetworkClient.active)
{
if (LogFilter.logError)
{
Debug.LogError("BecomeHost NetworkClient not active.");
}
return null;
}
Configure(hostTopology);
if (matchInfo == null)
{
if (LogFilter.logDev)
{
Debug.Log("BecomeHost Listen on " + port);
}
if (!Listen(port))
{
if (LogFilter.logError)
{
Debug.LogError("BecomeHost bind failed.");
}
return null;
}
}
else
{
if (LogFilter.logDev)
{
Debug.Log("BecomeHost match:" + matchInfo.networkId);
}
ListenRelay(matchInfo.address, matchInfo.port, matchInfo.networkId, Utility.GetSourceID(), matchInfo.nodeId);
}
foreach (NetworkIdentity identity in ClientScene.objects.Values)
{
if ((identity != null) && (identity.gameObject != null))
{
NetworkIdentity.AddNetworkId(identity.netId.Value);
this.m_NetworkScene.SetLocalObject(identity.netId, identity.gameObject, false, false);
identity.OnStartServer(true);
}
}
if (LogFilter.logDev)
{
Debug.Log("NetworkServer BecomeHost done. oldConnectionId:" + oldConnectionId);
}
this.RegisterMessageHandlers();
if (!NetworkClient.RemoveClient(oldClient) && LogFilter.logError)
{
Debug.LogError("BecomeHost failed to remove client");
}
if (LogFilter.logDev)
{
Debug.Log("BecomeHost localClient ready");
}
NetworkClient client2 = ClientScene.ReconnectLocalServer();
ClientScene.Ready(client2.connection);
ClientScene.SetReconnectId(oldConnectionId, peers);
ClientScene.AddPlayer(ClientScene.readyConnection, 0);
return client2;
}