• Api Documentation
  • Manual
Show / Hide Table of Contents
  • FishNet
    • InstanceFinder
  • FishNet.Authenticating
    • Authenticator
  • FishNet.Broadcast
    • IBroadcast
  • FishNet.Broadcast.Helping
    • BroadcastHandlerBase
  • FishNet.CodeGenerating
    • AllowMutableSyncTypeAttribute
    • CustomComparerAttribute
    • DefaultDeltaReaderAttribute
    • DefaultDeltaWriterAttribute
    • DefaultReaderAttribute
    • DefaultWriterAttribute
    • ExcludeSerializationAttribute
    • IncludeSerializationAttribute
    • NotSerializerAttribute
    • ReadUnallocatedAttribute
    • UseGlobalCustomSerializerAttribute
  • FishNet.Component.Animating
    • NetworkAnimator
  • FishNet.Component.ColliderRollback
    • ColliderRollback
    • RollbackManager
    • RollbackPhysicsType
  • FishNet.Component.Observing
    • DistanceCondition
    • GridCondition
    • GridEntry
    • HashGrid
    • HashGrid.GridAxes
    • HostOnlyCondition
    • MatchCondition
    • MatchCondition.ConditionCollections
    • OwnerOnlyCondition
    • SceneCondition
  • FishNet.Component.Ownership
    • PredictedOwner
    • PredictedSpawn
  • FishNet.Component.Prediction
    • NetworkCollider
    • NetworkCollider2D
    • NetworkCollision
    • NetworkCollision2D
    • NetworkTrigger
    • NetworkTrigger2D
    • OfflineRigidbody
    • Rigidbody2DState
    • RigidbodyPauser
    • RigidbodyState
    • RigidbodyStateExtensions
    • RigidbodyStateSerializers
    • RigidbodyType
  • FishNet.Component.Scenes
    • DefaultScene
  • FishNet.Component.Spawning
    • PlayerSpawner
  • FishNet.Component.Transforming
    • DetachableNetworkTickSmoother
    • MonoTickSmoother
    • NetworkTickSmoother
    • NetworkTransform
    • NetworkTransform.ComponentConfigurationType
    • NetworkTransform.GoalData
    • NetworkTransform.RateData
    • NetworkTransform.SnappedAxes
    • NetworkTransform.TransformData
    • NetworkTransform.TransformData.ExtrapolateState
    • SynchronizedProperty
  • FishNet.Component.Utility
    • BandwidthDisplay
    • PingDisplay
  • FishNet.Connection
    • NetworkConnection
    • NetworkConnectionExtensions
  • FishNet.Managing
    • NetworkManager
    • NetworkManager.HostIterationOrder
    • NetworkManager.PersistenceType
    • NetworkManagerExtensions
    • RemoteTimeoutType
  • FishNet.Managing.Client
    • ClientManager
    • ClientObjects
  • FishNet.Managing.Debugging
    • DebugManager
  • FishNet.Managing.Logging
    • LevelLoggingConfiguration
    • LoggingConfiguration
    • LoggingType
  • FishNet.Managing.Object
    • DualPrefab
    • ManagedObjects
  • FishNet.Managing.Observing
    • ObserverManager
  • FishNet.Managing.Predicting
    • PredictionManager
    • PredictionManager.PostPhysicsSyncTransformDel
    • PredictionManager.PostReconcileDel
    • PredictionManager.PostReplicateReplayDel
    • PredictionManager.PrePhysicsSyncTransformDel
    • PredictionManager.PreReconcileDel
    • PredictionManager.PreReplicateReplayDel
    • PredictionManager.ReconcileDel
    • PredictionManager.ReplicateReplayDel
    • ReplicateStateOrder
  • FishNet.Managing.Scened
    • ClientPresenceChangeEventArgs
    • DefaultSceneProcessor
    • EmptyStartScenesBroadcast
    • LoadOptions
    • LoadParams
    • LoadQueueData
    • PreferredScene
    • ReplaceOption
    • SceneLoadData
    • SceneLoadEndEventArgs
    • SceneLoadPercentEventArgs
    • SceneLoadStartEventArgs
    • SceneLookupData
    • SceneManager
    • SceneProcessorBase
    • SceneScopeType
    • SceneUnloadData
    • SceneUnloadEndEventArgs
    • SceneUnloadStartEventArgs
    • UnloadedScene
    • UnloadOptions
    • UnloadOptions.ServerUnloadMode
    • UnloadParams
    • UnloadQueueData
  • FishNet.Managing.Server
    • ClientConnectionChangeBroadcast
    • ConnectedClientsBroadcast
    • KickReason
    • ServerManager
    • ServerObjects
  • FishNet.Managing.Statistic
    • NetworkTrafficArgs
    • NetworkTraficStatistics
    • StatisticsManager
  • FishNet.Managing.Timing
    • EstimatedTick
    • EstimatedTick.OldTickOption
    • PhysicsMode
    • PreciseTick
    • PreciseTickExtensions
    • PreciseTickSerializer
    • TickRounding
    • TickType
    • TimeManager
  • FishNet.Managing.Transporting
    • IntermediateLayer
    • LatencySimulator
    • TransportManager
  • FishNet.Managing.Utility
    • Packets
  • FishNet.Object
    • ClientAttribute
    • DataOrderType
    • DespawnType
    • EmptyNetworkBehaviour
    • GlobalPreserveOwnedObjects
    • NetworkBehaviour
    • NetworkObject
    • NetworkObject.HostVisibilityUpdatedDelegate
    • NetworkObjectIdComparer
    • NetworkPreserveOwnedObjects
    • ObserversRpcAttribute
    • ReplicateState
    • ReplicateStateExtensions
    • RpcAttribute
    • ServerAttribute
    • ServerRpcAttribute
    • TargetRpcAttribute
    • TransformProperties
    • TransformPropertiesCls
    • TransformPropertiesFlag
    • TransformPropertiesOptionExtensions
  • FishNet.Object.Prediction
    • AdaptiveInterpolationType
    • ChildTransformTickSmoother
    • IReconcileData
    • IReplicateData
    • PredictionigidbodySerializers
    • PredictionRigidbody
    • PredictionRigidbody.AllForceData
    • PredictionRigidbody.EntryData
    • PredictionRigidbody.ForceApplicationType
    • PredictionRigidbody.IForceData
    • PredictionRigidbody2D
    • PredictionRigidbody2D.AllForceData
    • PredictionRigidbody2D.EntryData
    • PredictionRigidbody2D.ForceApplicationType
    • PredictionRigidbody2D2DSerializers
    • ReconcileAttribute
    • ReplicateAttribute
  • FishNet.Object.Synchronizing
    • ByteSyncVar
    • DoubleSyncVar
    • FloatSyncVar
    • ICustomSync
    • IntSyncVar
    • LongSyncVar
    • ReadPermission
    • SbyteSyncVar
    • ShortSyncVar
    • SyncDictionary<TKey, TValue>
    • SyncHashSet<T>
    • SyncList<T>
    • SyncObjectAttribute
    • SyncStopwatch
    • SyncStopwatch.SyncTypeChanged
    • SyncStopwatchOperation
    • SyncTimer
    • SyncTimer.SyncTypeChanged
    • SyncTimerOperation
    • SyncTypeSettings
    • SyncVarAttribute
    • UIntSyncVar
    • ULongSyncVar
    • UShortSyncVar
    • Vector2IntSyncVar
    • Vector2SyncVar
    • Vector3IntSyncVar
    • Vector3SyncVar
    • Vector4SyncVar
    • WritePermission
  • FishNet.Observing
    • HostVisibilityUpdateTypes
    • NetworkObserver
    • NetworkObserver.ConditionOverrideType
    • ObserverCondition
    • ObserverConditionType
  • FishNet.Serializing
    • AutoPackType
    • DeltaSerializerOption
    • DeltaSerializerOptionExtensions
    • PooledReader
    • PooledWriter
    • Reader
    • Reader.DataSource
    • ReaderPool
    • SubStream
    • Writer
    • WriterPool
  • FishNet.Transporting
    • Channel
    • ClientConnectionStateArgs
    • ClientReceivedDataArgs
    • ConnectedClientsArgs
    • IPAddressType
    • LocalConnectionState
    • RemoteConnectionState
    • RemoteConnectionStateArgs
    • ServerConnectionStateArgs
    • ServerReceivedDataArgs
    • Transport
    • TransportConsts
  • GameKit.Dependencies.Utilities
    • ApplicationState
    • Arrays
    • BasicQueue<T>
    • Booleans
    • Bytes
    • CanvaseGroups
    • CanvasGroupBlockingType
    • CollectionCaches<T>
    • CollectionCaches<T1, T2>
    • Collider2DExtensions
    • ColliderExtensions
    • DictionaryFN
    • Disks
    • Enums
    • Floats
    • Hashing
    • Ints
    • IOs
    • IResettable
    • IWeighted
    • Layers
    • LayoutGroups
    • Materials
    • Maths
    • ObjectCaches<T>
    • Objects
    • Particles
    • PointerMonoBehaviour
    • Quaternions
    • ResettableCollectionCaches<T>
    • ResettableCollectionCaches<T1, T2>
    • ResettableObjectCaches<T>
    • ResettableT1CollectionCaches<T1, T2>
    • ResettableT2CollectionCaches<T1, T2>
    • Strings
    • Transforms
    • UInts
    • Vectors
    • WeightedRandom
  • GameKit.Dependencies.Utilities.ObjectPooling
    • ListStack<GameObject>
    • ObjectPool
    • PoolData
  • GameKit.Dependencies.Utilities.ObjectPooling.Examples
    • Projectile
    • ProjectileSpawner
  • GameKit.Dependencies.Utilities.Types
    • ByteRange
    • CanvasGroupFader
    • CanvasGroupFader.FadeGoalType
    • CanvasTracker
    • DDOL
    • FloatRange
    • FloatRange2D
    • IntRange
    • IOrderable
    • RectTransformResizer
    • RectTransformResizer.ResizeData
    • RectTransformResizer.ResizeDelegate
    • ResettableRingBuffer<T>
    • ResettableRingBuffer<T>.Enumerator
    • RingBuffer<T>
    • RingBuffer<T>.Enumerator
    • SceneAttribute
    • ScrollbarValueSetter
    • SingletonScriptableObject<T>
    • SmoothCameraTarget
    • TimedOperation
    • UIntRange
    • Vector2Range
  • GameKit.Dependencies.Utilities.Types.CanvasContainers
    • ButtonData
    • ButtonData.PressedDelegate
    • FloatingContainer
    • FloatingImage
    • ImageButtonData
    • ResizableContainer
  • GameKit.Dependencies.Utilities.Types.OptionMenuButtons
    • FloatingOptions

Class NetworkConnection

A container for a connected client used to perform actions on and gather information for the declared client.

Inheritance
System.Object
NetworkConnection
Implements
IResettable
System.IEquatable<NetworkConnection>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: FishNet.Connection
Assembly: FishNet.Runtime.dll
Syntax
public class NetworkConnection : IResettable, IEquatable<NetworkConnection>

Fields

ClientId

Unique Id for this connection.

Declaration
public int ClientId
Field Value
Type Description
System.Int32

CLIENTID_UNCOMPRESSED_RESERVE_LENGTH

Number of bytes to reserve for a connectionId if writing the value uncompressed.

Declaration
public const int CLIENTID_UNCOMPRESSED_RESERVE_LENGTH = 4
Field Value
Type Description
System.Int32

CustomData

Custom data associated with this connection which may be modified by the user. The value of this field are not synchronized over the network.

Declaration
public object CustomData
Field Value
Type Description
System.Object

MAXIMUM_CLIENTID_VALUE

Maximum value a ClientId can be.

Declaration
public const int MAXIMUM_CLIENTID_VALUE = 2147483647
Field Value
Type Description
System.Int32

MAXIMUM_CLIENTID_WITHOUT_SIMULATED_VALUE

Maximum value a ClientId can be excluding simulated value.

Declaration
public const int MAXIMUM_CLIENTID_WITHOUT_SIMULATED_VALUE = 2147483646
Field Value
Type Description
System.Int32

Objects

Objects owned by this connection. Available to this connection and server.

Declaration
public HashSet<NetworkObject> Objects
Field Value
Type Description
System.Collections.Generic.HashSet<NetworkObject>

SIMULATED_CLIENTID_VALUE

Value to use as a ClientId when simulating a local client without actually using a socket.

Declaration
public const int SIMULATED_CLIENTID_VALUE = 2147483647
Field Value
Type Description
System.Int32

UNSET_CLIENTID_VALUE

Value used when ClientId has not been set.

Declaration
public const int UNSET_CLIENTID_VALUE = -1
Field Value
Type Description
System.Int32

Properties

Authenticated

Declaration
[Obsolete("Use IsAuthenticated.")]
public bool Authenticated { get; set; }
Property Value
Type Description
System.Boolean

Disconnecting

True if this connection is being disconnected. Only available to server.

Declaration
public bool Disconnecting { get; }
Property Value
Type Description
System.Boolean

FirstObject

The first object within Objects.

Declaration
public NetworkObject FirstObject { get; }
Property Value
Type Description
NetworkObject

IsActive

True if this connection IsValid and not Disconnecting.

Declaration
public bool IsActive { get; }
Property Value
Type Description
System.Boolean

IsAuthenticated

True if this connection is authenticated. Only available to server.

Declaration
public bool IsAuthenticated { get; }
Property Value
Type Description
System.Boolean

IsHost

Returns true if this connection is a clientHost.

Declaration
public bool IsHost { get; }
Property Value
Type Description
System.Boolean

IsLocalClient

Returns if this connection is for the local client.

Declaration
public bool IsLocalClient { get; }
Property Value
Type Description
System.Boolean

IsValid

True if this connection is valid. An invalid connection indicates no client is set for this reference.

Declaration
public bool IsValid { get; }
Property Value
Type Description
System.Boolean

LocalTick

Approximate local tick as it is on this connection. This also contains the last set value for local and remote.

Declaration
public EstimatedTick LocalTick { get; }
Property Value
Type Description
EstimatedTick

NetworkManager

NetworkManager managing this class.

Declaration
public NetworkManager NetworkManager { get; }
Property Value
Type Description
NetworkManager

PacketTick

Tick of the last packet received from this connection which was not out of order. This value is only available on the server.

Declaration
public EstimatedTick PacketTick { get; }
Property Value
Type Description
EstimatedTick

ReplicateTick

Approximate replicate tick on the server for this connection. This also contains the last set value for local and remote.

Declaration
public EstimatedTick ReplicateTick { get; }
Property Value
Type Description
EstimatedTick

Scenes

Scenes this connection is in. Available to this connection and server.

Declaration
public HashSet<Scene> Scenes { get; }
Property Value
Type Description
System.Collections.Generic.HashSet<UnityEngine.SceneManagement.Scene>

TransportIndex

TransportIndex this connection is on. For security reasons this value will be unset on clients if this is not their connection.

Declaration
public int TransportIndex { get; }
Property Value
Type Description
System.Int32

Methods

Broadcast<T>(T, Boolean, Channel)

Sends a broadcast to this connection.

Declaration
public void Broadcast<T>(T message, bool requireAuthenticated = true, Channel channel = Channel.Reliable)
    where T : struct, IBroadcast
Parameters
Type Name Description
T message

Broadcast data being sent; for example: an instance of your broadcast type.

System.Boolean requireAuthenticated

True if the client must be authenticated for this broadcast to send.

Channel channel

Channel to send on.

Type Parameters
Name Description
T

Type of broadcast to send.

Disconnect(Boolean)

Disconnects this connection.

Declaration
public void Disconnect(bool immediately)
Parameters
Type Name Description
System.Boolean immediately

True to disconnect immediately. False to send any pending data first.

Equals(NetworkConnection)

Declaration
public bool Equals(NetworkConnection nc)
Parameters
Type Name Description
NetworkConnection nc
Returns
Type Description
System.Boolean

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean
Overrides
System.Object.Equals(System.Object)

GetAddress()

Returns the address of this connection.

Declaration
public string GetAddress()
Returns
Type Description
System.String

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.Object.GetHashCode()

InitializeState()

Declaration
public void InitializeState()

Kick(KickReason, LoggingType, String)

Kicks a connection immediately while invoking OnClientKick.

Declaration
public void Kick(KickReason kickReason, LoggingType loggingType = LoggingType.Common, string log = "")
Parameters
Type Name Description
KickReason kickReason

Reason client is being kicked.

LoggingType loggingType

How to print logging as.

System.String log

Optional message to be debug logged.

Kick(Reader, KickReason, LoggingType, String)

Kicks a connection immediately while invoking OnClientKick.

Declaration
public void Kick(Reader reader, KickReason kickReason, LoggingType loggingType = LoggingType.Common, string log = "")
Parameters
Type Name Description
Reader reader

Reader to clear before kicking.

KickReason kickReason

Reason client is being kicked.

LoggingType loggingType

How to print logging as.

System.String log

Optional message to be debug logged.

LoadedStartScenes()

True if connection has loaded start scenes. Available to this connection and server.

Declaration
public bool LoadedStartScenes()
Returns
Type Description
System.Boolean

LoadedStartScenes(Boolean)

Declaration
public bool LoadedStartScenes(bool asServer)
Parameters
Type Name Description
System.Boolean asServer
Returns
Type Description
System.Boolean

ResetState()

Resets all states for re-use.

Declaration
public void ResetState()

SetFirstObject(NetworkObject)

Sets a custom FirstObject. This connection must be owner of the specified object.

Declaration
public void SetFirstObject(NetworkObject nob)
Parameters
Type Name Description
NetworkObject nob

ToString()

Outputs data about this connection as a string.

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.Object.ToString()

Events

OnLoadedStartScenes

Called after this connection has loaded start scenes. Boolean will be true if asServer. Available to this connection and server.

Declaration
public event Action<NetworkConnection, bool> OnLoadedStartScenes
Event Type
Type Description
System.Action<NetworkConnection, System.Boolean>

OnObjectAdded

Called after connection gains ownership of an object, and after the object has been added to Objects. Available to this connection and server.

Declaration
public event Action<NetworkObject> OnObjectAdded
Event Type
Type Description
System.Action<NetworkObject>

OnObjectRemoved

Called after connection loses ownership of an object, and after the object has been removed from Objects. Available to this connection and server.

Declaration
public event Action<NetworkObject> OnObjectRemoved
Event Type
Type Description
System.Action<NetworkObject>

Operators

Equality(NetworkConnection, NetworkConnection)

Declaration
public static bool operator ==(NetworkConnection a, NetworkConnection b)
Parameters
Type Name Description
NetworkConnection a
NetworkConnection b
Returns
Type Description
System.Boolean

Inequality(NetworkConnection, NetworkConnection)

Declaration
public static bool operator !=(NetworkConnection a, NetworkConnection b)
Parameters
Type Name Description
NetworkConnection a
NetworkConnection b
Returns
Type Description
System.Boolean

Implements

IResettable
System.IEquatable<T>

Extension Methods

NetworkConnectionExtensions.IsValid(NetworkConnection)
In This Article
Back to top Generated by DocFX