This commit is contained in:
vis2k 2021-03-13 19:49:45 +08:00
parent b9027737c8
commit df2330239f

View File

@ -10,6 +10,7 @@ public abstract class NetworkConnection
public const int LocalConnectionId = 0;
// NetworkIdentities that this connection can see
// TODO move to server's NetworkConnectionToClient?
internal readonly HashSet<NetworkIdentity> observing = new HashSet<NetworkIdentity>();
// TODO this is NetworkServer.handlers on server and NetworkClient.handlers on client.
@ -113,6 +114,7 @@ protected static bool ValidatePacketSize(ArraySegment<byte> segment, int channel
public override string ToString() => $"connection({connectionId})";
// TODO move to server's NetworkConnectionToClient?
internal void AddToObserving(NetworkIdentity netIdentity)
{
observing.Add(netIdentity);
@ -121,6 +123,7 @@ internal void AddToObserving(NetworkIdentity netIdentity)
NetworkServer.ShowForConnection(netIdentity, this);
}
// TODO move to server's NetworkConnectionToClient?
internal void RemoveFromObserving(NetworkIdentity netIdentity, bool isDestroyed)
{
observing.Remove(netIdentity);
@ -132,6 +135,7 @@ internal void RemoveFromObserving(NetworkIdentity netIdentity, bool isDestroyed)
}
}
// TODO move to server's NetworkConnectionToClient?
internal void RemoveObservers()
{
foreach (NetworkIdentity netIdentity in observing)