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() internal void InternalConnectLocalServer()
{ {
// create local connection to server // create local connection to server
connection = new ULocalConnectionToServer() connection = new ULocalConnectionToServer();
{
// local player always has connectionId == 0
connectionId = 0
};
SetHandlers(connection); SetHandlers(connection);
// create server connection to local client // create server connection to local client
ULocalConnectionToClient connectionToClient = new ULocalConnectionToClient(this) ULocalConnectionToClient connectionToClient = new ULocalConnectionToClient(this);
{
// local player always has connectionId == 0
connectionId = 0
};
NetworkServer.SetLocalConnection(connectionToClient); NetworkServer.SetLocalConnection(connectionToClient);
connectState = ConnectState.Connected; connectState = ConnectState.Connected;

View File

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