Fish-Net: Networking Evolved
  • Overview
    • What is FishNet?
      • Features
        • Unity Compatibility
        • Performance
          • Benchmark Setup
          • Fish-Networking Vs Mirror
      • Pro, Projects, and Support
      • Business Support
      • Development
        • Changelog
        • Roadmap
      • Branding
      • Legal Restrictions
    • Showcase
      • Upcoming Releases
    • Asset Integrations
      • Fish-Network-Discovery
    • Community Resources
  • Guides
    • Getting Started
      • Installing Fish-Networking
      • Getting Connected
      • Preparing Your Player
      • Moving Your Player Around
      • Spawning and Despawning Items
      • Using SyncVars to Sync Colors
      • Connecting to Remote Devices
      • Beyond the Basics
    • High-Level Overview
      • Fundamentals
      • Networking Models
      • Terminology
        • Server, Client, Host
        • Communicating
        • Miscellaneous
      • Transports
    • Features
      • Server and Client Identification
        • Executing on Server or Client
        • NetworkConnections
      • Networked GameObjects and Scripts
        • NetworkObjects
        • NetworkBehaviour
        • Spawning and Despawning
          • Predicted Spawning
          • Nested NetworkObjects
          • Object Pooling
      • Network State Events
      • Network Communication
        • Remote Procedure Calls
        • SyncTypes
          • Customizing Behavior
          • SyncVar
          • SyncList
          • SyncHashSet
          • SyncDictionary
          • SyncTimer
          • SyncStopwatch
          • Custom SyncType
        • Broadcasts
      • Data Serialization
        • Custom Serializers
          • Interface Serializers
          • Inheritance Serializers
      • Ownership
        • Using Ownership To Read Values
      • Area of Interest (Observer System)
        • Modifying Conditions
        • Custom Conditions
      • Scene Management
        • Scene Events
        • Scene Data
          • SceneLookupData
          • SceneLoadData
          • SceneUnloadData
        • Loading Scenes
          • Automatic Online and Offline Scenes
        • Unloading Scenes
        • Scene Stacking
        • Scene Caching
        • Scene Visibility
        • Persisting NetworkObjects
        • Custom Scene Processors
          • Addressables
      • InstanceFinder
      • Addressables
      • Transports
        • Multipass
      • Prediction
        • What Is Client-Side Prediction
        • Configuring PredictionManager
        • Configuring TimeManager
        • Configuring NetworkObject
        • Offline Rigidbodies
        • Interpolations
        • Creating Code
          • Controlling An Object
          • Non-Controlled Object
          • Understanding ReplicateState
            • Using States In Code
            • Predicting States In Code
          • Advanced Controls
        • Custom Comparers
        • PredictionRigidbody
        • Using NetworkColliders
      • Lag Compensation
        • States
        • Raycast
        • Projectiles
    • Upgrading API
    • Server Hosting
      • Edgegap - Official Partner
        • Getting Started with Edgegap
      • Hathora
        • Getting Started with Hathora
      • Amazon Web Services (AWS)
        • Getting Started with AWS
    • Upgrading To Fish-Networking
    • Troubleshooting
      • Technical Limitations
      • Creating Bug Reports
        • Report Example
      • FAQ
  • FishNet Building Blocks
    • Components
      • Managers
        • NetworkManager
        • TimeManager
        • PredictionManager
        • ServerManager
        • ClientManager
        • SceneManager
        • TransportManager
          • IntermediateLayer
        • StatisticsManager
        • ObserverManager
          • HashGrid
        • RollbackManager (Pro Feature)
      • Prediction
        • Network Collider
          • NetworkCollision
          • NetworkCollision2D
          • NetworkTrigger
          • NetworkTrigger2D
        • OfflineRigidbody
        • PredictedOwner
        • PredictedSpawn
      • Utilities
        • PingDisplay
        • BandwidthDisplay
        • Tick Smoothers
          • NetworkTickSmoother
          • OfflineTickSmoother
          • MonoTickSmoother [Obsolete]
          • DetachableNetworkTickSmoother [Obsolete]
      • PlayerSpawner
      • DefaultScene
      • ServerSpawner
      • Authenticator
      • ColliderRollback
      • NetworkAnimator
      • NetworkBehaviour
      • NetworkTransform
      • NetworkObject
      • NetworkObserver
    • Prefabs
      • NetworkManager
      • NetworkHudCanvas
    • ScriptableObjects
      • ObserverConditions
        • DistanceCondition
        • GridCondition
        • HostOnlyCondition
        • MatchCondition
        • OwnerOnlyCondition
        • SceneCondition
      • SpawnablePrefabs
        • DefaultPrefabObjects
        • SinglePrefabObjects
        • DualPrefabObjects
      • LevelLoggingConfiguration
    • Transports
      • Tugboat
      • Multipass
      • Yak (Pro Feature)
      • Bayou
      • FishyWebRTC
      • FishyUnityTransport
      • FishySteamworks (Steam)
      • FishyEOS (Epic Online Services)
      • FishyFacepunch (Steam)
      • FishyRealtime (Photon)
  • API Documentation
    • API Reference
Powered by GitBook
On this page
  • NetworkConnections
  • Purposes
  • Important Fields and Properties
  • Where to get them and where to use them?
  1. Guides
  2. Features
  3. Server and Client Identification

NetworkConnections

A look at how Fish-Networking distinguishes clients from one another.

PreviousExecuting on Server or ClientNextNetworked GameObjects and Scripts

Last updated 1 day ago

NetworkConnections

A NetworkConnection in FishNet is a core object that represents a single connected client within the networking system. As soon as a client connects to the server, a NetworkConnection is created to represent it, perform actions on it, and gather information about that specific client.

Purposes

  • Client Representation: Each connected player/client has a corresponding NetworkConnection instance. This object tracks the client's identity, state, and the objects it owns.

  • Ownership and Authority: NetworkConnection tracks which networked objects (such as player avatars) the client owns, enabling authority checks and state management.

  • Authentication and State: It manages authentication state, and notes if it’s disconnecting.

  • Scene Tracking It is used to track which networked scenes the client has loaded into.

  • Events: It provides events for actions like gaining or losing ownership of objects and loading start scenes.

  • Custom Data: Developers can associate custom data with a connection for gameplay or server logic. (This data is not automatically synchronized across the network.)

  • Disconnection: Provides methods to disconnect the client, either immediately or after sending pending data.


Important Fields and Properties

ClientId — One important field is the . This is a unique ID for the NetworkConnection and it is used in a few other places in Fish-Networking. If a ClientId is not set, it defaults to -1, and generally ClientIds increment from 0 until the maximum integer value before reusing old ones from the beginning.

FirstObject — FishNet doesn't have a forced Player GameObject, but you can get the first object owned by a client with the FirstObject property. You can also set it with the SetFirstObject method, which can be useful if you have the object destroyed and re-instantiated.

Objects — This field is a HashSet of all the network objects owned by this connection. It is available to this connection and server.

Scenes — These are the networked scenes this connection is considered a part of.

CustomData — As mentioned above, this is a user-definable object for storing arbitrary data on the connection. It is not synced at all.


Where to get them and where to use them?

How is it created/used?

  • Each client has a NetworkConnection representing itself, this can be accessed with ClientManager.Connection, or LocalConnecton from within a NetworkBehaviour.

  • The server maintains a dictionary of NetworkConnection instances for all connected clients, this is available at ServerManager.Clients. It is also available on clients under the ClientManager.Clients. You should use the ServerManager version if the instance is running as a server. The dictionary key is the Client ID and the value is the NetworkConnection.

  • NetworkObjects can have an owner, which is a NetworkConnection that has authority over the object. From the NetworkObject or NetworkBehaviour you can get the NetworkConnection with the Owner property.

Many more useful fields, properties, and methods are available and can be found in the .

When calling you will need to provide a NetworkConnection as the first argument of the method, this represents which client you will send the RPC to.

ClientId
API page
TargetRpcs