mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Remove hostId from NetworkServer and NetworkConnection because it was only needed for the old LLAPI. Also added comment for NetworkConnection.isConnected which can be removed later.
This commit is contained in:
parent
74b297819b
commit
619d5f47e3
@ -59,7 +59,7 @@ public void Connect(string ip)
|
||||
NetworkManager.singleton.transport.ClientConnect(ip);
|
||||
|
||||
// setup all the handlers
|
||||
connection = new NetworkConnection(serverIp, 0, 0);
|
||||
connection = new NetworkConnection(serverIp, 0);
|
||||
connection.SetHandlers(handlers);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@ public class NetworkConnection : IDisposable
|
||||
|
||||
Dictionary<short, NetworkMessageDelegate> m_MessageHandlers;
|
||||
|
||||
public int hostId = -1;
|
||||
public int connectionId = -1;
|
||||
public bool isReady;
|
||||
public string address;
|
||||
@ -19,17 +18,20 @@ public class NetworkConnection : IDisposable
|
||||
public NetworkIdentity playerController => m_PlayerController;
|
||||
public HashSet<uint> clientOwnedObjects;
|
||||
public bool logNetworkMessages;
|
||||
public bool isConnected => hostId != -1;
|
||||
|
||||
// this is always true for regular connections, false for local
|
||||
// connections because it's set in the constructor and never reset.
|
||||
public bool isConnected { get; protected set; }
|
||||
|
||||
public NetworkConnection(string networkAddress)
|
||||
{
|
||||
address = networkAddress;
|
||||
}
|
||||
public NetworkConnection(string networkAddress, int networkHostId, int networkConnectionId)
|
||||
public NetworkConnection(string networkAddress, int networkConnectionId)
|
||||
{
|
||||
address = networkAddress;
|
||||
hostId = networkHostId;
|
||||
connectionId = networkConnectionId;
|
||||
isConnected = true;
|
||||
}
|
||||
|
||||
~NetworkConnection()
|
||||
@ -82,11 +84,8 @@ public void Disconnect()
|
||||
NetworkManager.singleton.transport.ServerDisconnect(connectionId);
|
||||
}
|
||||
|
||||
// remove observers. original HLAPI has hostId check for that too.
|
||||
if (hostId != -1)
|
||||
{
|
||||
RemoveObservers();
|
||||
}
|
||||
// remove observers
|
||||
RemoveObservers();
|
||||
}
|
||||
|
||||
internal void SetHandlers(Dictionary<short, NetworkMessageDelegate> handlers)
|
||||
@ -149,7 +148,7 @@ internal virtual bool SendBytes( byte[] bytes, int channelId = Channels.DefaultR
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("hostId: {0} connectionId: {1} isReady: {2}", hostId, connectionId, isReady);
|
||||
return string.Format("connectionId: {0} isReady: {1}", connectionId, isReady);
|
||||
}
|
||||
|
||||
internal void AddToVisList(NetworkIdentity identity)
|
||||
|
@ -17,8 +17,6 @@ public static class NetworkServer
|
||||
// => removed it for easier code. use .localConection now!
|
||||
public static NetworkConnection localConnection => s_LocalConnection;
|
||||
|
||||
public static int serverHostId { get; private set; } = -1;
|
||||
|
||||
// <connectionId, NetworkConnection>
|
||||
public static Dictionary<int, NetworkConnection> connections = new Dictionary<int, NetworkConnection>();
|
||||
public static Dictionary<short, NetworkMessageDelegate> handlers = new Dictionary<short, NetworkMessageDelegate>();
|
||||
@ -46,7 +44,6 @@ public static void Shutdown()
|
||||
else
|
||||
{
|
||||
NetworkManager.singleton.transport.ServerStop();
|
||||
serverHostId = -1;
|
||||
}
|
||||
|
||||
NetworkManager.singleton.transport.OnServerDisconnected.RemoveListener(OnDisconnected);
|
||||
@ -94,7 +91,6 @@ public static bool Listen(int maxConnections)
|
||||
if (!dontListen)
|
||||
{
|
||||
NetworkManager.singleton.transport.ServerStart();
|
||||
serverHostId = 0; // so it doesn't return false
|
||||
if (LogFilter.Debug) { Debug.Log("Server started listening"); }
|
||||
}
|
||||
|
||||
@ -278,10 +274,10 @@ static void UpdateServerObjects()
|
||||
// The user should never need to pump the update loop manually
|
||||
internal static void Update()
|
||||
{
|
||||
if (serverHostId == -1)
|
||||
return;
|
||||
|
||||
UpdateServerObjects();
|
||||
if (active)
|
||||
{
|
||||
UpdateServerObjects();
|
||||
}
|
||||
}
|
||||
|
||||
static void OnConnected(int connectionId)
|
||||
@ -315,7 +311,7 @@ static void OnConnected(int connectionId)
|
||||
string address = NetworkManager.singleton.transport.ServerGetClientAddress(connectionId);
|
||||
|
||||
// add player info
|
||||
NetworkConnection conn = new NetworkConnection(address, serverHostId, connectionId);
|
||||
NetworkConnection conn = new NetworkConnection(address, connectionId);
|
||||
OnConnected(conn);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user