2using System.Collections.Generic;
3using System.Runtime.CompilerServices;
9 public override string address =>
14 public new readonly HashSet<NetworkIdentity>
observing =
new HashSet<NetworkIdentity>();
21 public new readonly HashSet<NetworkIdentity>
clientOwnedObjects =
new HashSet<NetworkIdentity>();
27 : base(networkConnectionId) {}
30 [MethodImpl(MethodImplOptions.AggressiveInlining)]
31 protected override void SendToTransport(ArraySegment<byte> segment,
int channelId =
Channels.Reliable) =>
57 internal void RemoveFromObserving(NetworkIdentity netIdentity,
bool isDestroyed)
64 NetworkServer.HideForConnection(netIdentity,
this);
68 internal void RemoveFromObservingsObservers()
70 foreach (NetworkIdentity netIdentity
in observing)
72 netIdentity.RemoveObserver(
this);
77 internal void AddOwnedObject(NetworkIdentity obj)
82 internal void RemoveOwnedObject(NetworkIdentity obj)
87 internal void DestroyOwnedObjects()
91 foreach (NetworkIdentity netIdentity
in tmp)
93 if (netIdentity !=
null)
95 NetworkServer.Destroy(netIdentity.gameObject);
Base NetworkConnection class for server-to-client and client-to-server connection.
readonly int connectionId
Unique identifier for this connection that is assigned by the transport layer.
bool isReady
A server connection is ready after joining the game world.
new readonly HashSet< NetworkIdentity > clientOwnedObjects
All NetworkIdentities owned by this connection. Can be main player, pets, etc.
override void Disconnect()
Disconnects this connection.
new readonly HashSet< NetworkIdentity > observing
NetworkIdentities that this connection can see
NetworkIdentity identifies objects across the network.
NetworkServer handles remote connections and has a local connection for a local client.
Abstract transport layer component
static Transport activeTransport
The current transport used by Mirror.
abstract void ServerSend(int connectionId, ArraySegment< byte > segment, int channelId=Channels.Reliable)
Send a message to a client over the given channel.
abstract string ServerGetClientAddress(int connectionId)
Get a client's address on the server.
abstract void ServerDisconnect(int connectionId)
Disconnect a client from the server.