docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct NetworkDriverStore

    Store and manage an array of NetworkDriver. The capacity is fixed to Capacity. The driver registration should start by calling BeginDriverRegistration() and terminate with EndDriverRegistration(). The store also provide some accessor and utlilty methods.

    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Unity.NetCode
    Assembly: Unity.NetCode.dll
    Syntax
    public struct NetworkDriverStore

    Fields

    Capacity

    The fixed capacity of the driver container.

    Declaration
    public const int Capacity = 3
    Field Value
    Type Description
    int

    FirstDriverId

    The first assigned uniqued identifier to each driver.

    Declaration
    public const int FirstDriverId = 1
    Field Value
    Type Description
    int

    Properties

    DriversCount

    The number of registed drivers. Must be always less then the total driver Capacity.

    Declaration
    public int DriversCount { get; }
    Property Value
    Type Description
    int

    FirstDriver

    The first driver id present in the store. Can be used to iterate over all registered drivers in a for loop.

    Declaration
    public int FirstDriver { get; }
    Property Value
    Type Description
    int
    Examples
      for(int i= driverStore.FirstDriver; i < driverStore.LastDriver; ++i)
                 {
                      ref var instance = ref driverStore.GetDriverInstance(i);
                      ....
                 }
    

    IsAnyUsingSimulator

    Return true if the driver store contains a driver that has a simulator pipeline.

    Declaration
    public bool IsAnyUsingSimulator { get; }
    Property Value
    Type Description
    bool

    LastDriver

    The last driver id present in the store. Can be used to iterate over all registered drivers in a for loop.

    Declaration
    public int LastDriver { get; }
    Property Value
    Type Description
    int
    Examples
      for(int i= driverStore.FirstDriver; i < driverStore.LastDriver; ++i)
                 {
                      ref var instance = ref driverStore.GetDriverInstance(i).
                      ....
                 }
    

    Methods

    Disconnect(NetworkStreamConnection)

    Utility method to disconnect the NetworkStreamConnection connection.

    Declaration
    public void Disconnect(NetworkStreamConnection connection)
    Parameters
    Type Name Description
    NetworkStreamConnection connection
    Exceptions
    Type Condition
    InvalidOperationException

    Dispose()

    Dispose all the registered drivers instances and their allocated resources.

    Declaration
    public void Dispose()

    ForEachDriver(DriverVisitor)

    Invoke the delegate on all registered drivers.

    Declaration
    public void ForEachDriver(NetworkDriverStore.DriverVisitor visitor)
    Parameters
    Type Name Description
    NetworkDriverStore.DriverVisitor visitor

    GetConnectionState(NetworkStreamConnection)

    Return the state of the NetworkStreamConnection connection.

    Declaration
    public NetworkConnection.State GetConnectionState(NetworkStreamConnection connection)
    Parameters
    Type Name Description
    NetworkStreamConnection connection

    A client or server connection

    Returns
    Type Description
    NetworkConnection.State
    Exceptions
    Type Condition
    InvalidOperationException

    Throw an exception if the driver associated to the connection is not found

    GetDriverInstance(int)

    Return the NetworkDriverStore.NetworkDriverInstance instance with the given driverId.

    Declaration
    public readonly NetworkDriverStore.NetworkDriverInstance GetDriverInstance(int driverId)
    Parameters
    Type Name Description
    int driverId

    the id of the driver. Should be always greater or equals than FirstDriverId

    Returns
    Type Description
    NetworkDriverStore.NetworkDriverInstance

    The NetworkDriverStore.NetworkDriverInstance at for the given id.

    Remarks

    The method return a copy of the driver instance not a reference. While this is suitable for almost all the use cases, since the driver is trivially copyable, be aware that calling some of the Driver class methods, like ScheduleUpdate, that update internal driver data (that aren't suited to be copied around) may not work as expected.

    Exceptions
    Type Condition
    InvalidOperationException

    Throw an exception if a driver is not found

    GetDriverType(int)

    Return the transport type used by the registered driver.

    Declaration
    public TransportType GetDriverType(int driverId)
    Parameters
    Type Name Description
    int driverId

    the id of the driver. Should be always greater or equals than FirstDriverId

    Returns
    Type Description
    TransportType

    The TransportType of driver

    Exceptions
    Type Condition
    InvalidOperationException

    Throw an exception if a driver is not found

    GetNetworkDriver(int)

    Return the Unity.Networking.Transport.NetworkDriver with the given driver id.

    Declaration
    public readonly NetworkDriver GetNetworkDriver(int driverId)
    Parameters
    Type Name Description
    int driverId

    the id of the driver. Should be always greater or equals than FirstDriverId

    Returns
    Type Description
    NetworkDriver

    The NetworkDriverStore.NetworkDriverInstance at for the given id.

    Exceptions
    Type Condition
    InvalidOperationException

    Throw an exception if a driver is not found

    RegisterDriver(TransportType, in NetworkDriverInstance)

    Add a new driver to the store. Throw exception if all drivers slot are already occupied or the driver is not created/valid

    Declaration
    public int RegisterDriver(TransportType driverType, in NetworkDriverStore.NetworkDriverInstance driverInstance)
    Parameters
    Type Name Description
    TransportType driverType
    NetworkDriverStore.NetworkDriverInstance driverInstance
    Returns
    Type Description
    int

    The assigned driver id

    Exceptions
    Type Condition
    InvalidOperationException

    ScheduleFlushSendAllDrivers(JobHandle)

    Invoke ScheduleFlushSend(JobHandle) on all registered drivers in the store

    Declaration
    public JobHandle ScheduleFlushSendAllDrivers(JobHandle dependency)
    Parameters
    Type Name Description
    JobHandle dependency

    A job handle whom all flush jobs depend upon

    Returns
    Type Description
    JobHandle

    The combined handle of all the scheduled jobs.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)