Local Connection's connectionId is now set to 0 inside of their constructors, instead of doing it in LocalClient

This commit is contained in:
vis2k 2019-03-24 21:16:55 +01:00
parent 5f7c4d48b4
commit 7836433b4f
2 changed files with 10 additions and 11 deletions

View File

@ -13,19 +13,11 @@ sealed class LocalClient : NetworkClient
internal void InternalConnectLocalServer()
{
// create local connection to server
connection = new ULocalConnectionToServer()
{
// local player always has connectionId == 0
connectionId = 0
};
connection = new ULocalConnectionToServer();
SetHandlers(connection);
// create server connection to local client
ULocalConnectionToClient connectionToClient = new ULocalConnectionToClient(this)
{
// local player always has connectionId == 0
connectionId = 0
};
ULocalConnectionToClient connectionToClient = new ULocalConnectionToClient(this);
NetworkServer.SetLocalConnection(connectionToClient);
connectState = ConnectState.Connected;

View File

@ -11,6 +11,9 @@ class ULocalConnectionToClient : NetworkConnection
public ULocalConnectionToClient(LocalClient localClient) : base ("localClient")
{
this.localClient = localClient;
// local player always has connectionId == 0
connectionId = 0;
}
internal override bool SendBytes(byte[] bytes, int channelId = Channels.DefaultReliable)
@ -24,7 +27,11 @@ internal override bool SendBytes(byte[] bytes, int channelId = Channels.DefaultR
// send messages on this connection causes the server's handler function to be invoked directly.
internal class ULocalConnectionToServer : NetworkConnection
{
public ULocalConnectionToServer() : base("localServer") {}
public ULocalConnectionToServer() : base("localServer")
{
// local player always has connectionId == 0
connectionId = 0;
}
internal override bool SendBytes(byte[] bytes, int channelId = Channels.DefaultReliable)
{