NetworkClient.ConnectHost: local connection setup moved into a separate function

This commit is contained in:
vis2k 2022-12-12 13:53:07 +01:00
parent 1b7906c1ed
commit e0ffc66be8

View File

@ -212,14 +212,10 @@ public static void Connect(Uri uri)
connection = new NetworkConnectionToServer(); connection = new NetworkConnectionToServer();
} }
// TODO why are there two connect host methods? // keep the local connections setup in one function.
// called from NetworkManager.FinishStartHost() // makes host setup easier to follow.
public static void ConnectHost() internal static void SetupHostConnections()
{ {
Initialize(true);
connectState = ConnectState.Connected;
// create local connections pair, both are connected // create local connections pair, both are connected
Utils.CreateLocalConnections( Utils.CreateLocalConnections(
out LocalConnectionToClient connectionToClient, out LocalConnectionToClient connectionToClient,
@ -231,6 +227,15 @@ public static void ConnectHost()
NetworkServer.SetLocalConnection(connectionToClient); NetworkServer.SetLocalConnection(connectionToClient);
} }
// TODO why are there two connect host methods?
// called from NetworkManager.FinishStartHost()
public static void ConnectHost()
{
Initialize(true);
connectState = ConnectState.Connected;
SetupHostConnections();
}
/// <summary>Connect host mode</summary> /// <summary>Connect host mode</summary>
// called from NetworkManager.FinishStartHostClient // called from NetworkManager.FinishStartHostClient
// TODO why are there two connect host methods? // TODO why are there two connect host methods?