mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Utils.CreateLocalConnections for use from NetworkClient.ConnectHost & Tests
This commit is contained in:
parent
65c73bd158
commit
d406a55e49
@ -220,11 +220,10 @@ public static void ConnectHost()
|
||||
|
||||
connectState = ConnectState.Connected;
|
||||
|
||||
// create local connection objects and connect them
|
||||
LocalConnectionToServer connectionToServer = new LocalConnectionToServer();
|
||||
LocalConnectionToClient connectionToClient = new LocalConnectionToClient();
|
||||
connectionToServer.connectionToClient = connectionToClient;
|
||||
connectionToClient.connectionToServer = connectionToServer;
|
||||
// create local connections pair, both are connected
|
||||
Utils.CreateLocalConnections(
|
||||
out LocalConnectionToClient connectionToClient,
|
||||
out LocalConnectionToServer connectionToServer);
|
||||
|
||||
connection = connectionToServer;
|
||||
|
||||
|
@ -166,5 +166,16 @@ public static Rect KeepInScreen(Rect rect)
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
// create local connections pair and connect them
|
||||
public static void CreateLocalConnections(
|
||||
out LocalConnectionToClient connectionToClient,
|
||||
out LocalConnectionToServer connectionToServer)
|
||||
{
|
||||
connectionToServer = new LocalConnectionToServer();
|
||||
connectionToClient = new LocalConnectionToClient();
|
||||
connectionToServer.connectionToClient = connectionToClient;
|
||||
connectionToClient.connectionToServer = connectionToServer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -654,14 +654,5 @@ protected void ProcessMessages()
|
||||
// update transport so sent messages are received
|
||||
UpdateTransport();
|
||||
}
|
||||
|
||||
// helper function to create local connection pair
|
||||
protected void CreateLocalConnectionPair(out LocalConnectionToClient connectionToClient, out LocalConnectionToServer connectionToServer)
|
||||
{
|
||||
connectionToClient = new LocalConnectionToClient();
|
||||
connectionToServer = new LocalConnectionToServer();
|
||||
connectionToClient.connectionToServer = connectionToServer;
|
||||
connectionToServer.connectionToClient = connectionToClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
CreateLocalConnectionPair(out connectionToClient, out connectionToServer);
|
||||
Utils.CreateLocalConnections(out connectionToClient, out connectionToServer);
|
||||
|
||||
// set up server/client connections so message handling works
|
||||
NetworkClient.connection = connectionToServer;
|
||||
|
@ -527,7 +527,7 @@ public void AssignAndRemoveClientAuthority()
|
||||
};
|
||||
|
||||
// create connections
|
||||
CreateLocalConnectionPair(out LocalConnectionToClient owner, out LocalConnectionToServer clientConnection);
|
||||
Utils.CreateLocalConnections(out LocalConnectionToClient owner, out LocalConnectionToServer clientConnection);
|
||||
owner.isReady = true;
|
||||
|
||||
// setup NetworkServer/Client connections so messages are handled
|
||||
|
@ -214,7 +214,7 @@ public void RemoveLocalConnection()
|
||||
NetworkServer.Listen(1);
|
||||
|
||||
// set local connection
|
||||
CreateLocalConnectionPair(out LocalConnectionToClient connectionToClient, out _);
|
||||
Utils.CreateLocalConnections(out LocalConnectionToClient connectionToClient, out _);
|
||||
NetworkServer.SetLocalConnection(connectionToClient);
|
||||
|
||||
// remove local connection
|
||||
@ -1221,7 +1221,7 @@ public void HasExternalConnections_WithConnections()
|
||||
[Test]
|
||||
public void HasExternalConnections_WithHostOnly()
|
||||
{
|
||||
CreateLocalConnectionPair(out LocalConnectionToClient connectionToClient, out _);
|
||||
Utils.CreateLocalConnections(out LocalConnectionToClient connectionToClient, out _);
|
||||
|
||||
NetworkServer.SetLocalConnection(connectionToClient);
|
||||
NetworkServer.connections.Add(0, connectionToClient);
|
||||
@ -1235,7 +1235,7 @@ public void HasExternalConnections_WithHostOnly()
|
||||
[Test]
|
||||
public void HasExternalConnections_WithHostAndConnection()
|
||||
{
|
||||
CreateLocalConnectionPair(out LocalConnectionToClient connectionToClient, out _);
|
||||
Utils.CreateLocalConnections(out LocalConnectionToClient connectionToClient, out _);
|
||||
|
||||
NetworkServer.SetLocalConnection(connectionToClient);
|
||||
NetworkServer.connections.Add(0, connectionToClient);
|
||||
|
Loading…
Reference in New Issue
Block a user