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.
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
FirstDriverId
The first assigned uniqued identifier to each driver.
Declaration
public const int FirstDriverId = 1
Field Value
Properties
DriversCount
The number of registered drivers. Must be always less then the total driver Capacity.
Declaration
public int DriversCount { get; }
Property Value
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
Examples
for(int i= driverStore.FirstDriver; i < driverStore.LastDriver; ++i)
{
ref var instance = ref driverStore.GetDriverInstance(i);
....
}
HasListeningInterfaces
Return true if there is at least one driver listening for incoming connections.
Declaration
public bool HasListeningInterfaces { get; }
Property Value
IsAnyUsingSimulator
Return true if the driver store contains a driver that has a simulator pipeline.
Declaration
public bool IsAnyUsingSimulator { get; }
Property Value
IsCreated
Denote if the store has at least one driver registered
Declaration
public bool IsCreated { get; }
Property Value
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
Examples
for(int i= driverStore.FirstDriver; i < driverStore.LastDriver; ++i)
{
ref var instance = ref driverStore.GetDriverInstance(i).
....
}
Methods
Disconnect(NetworkStreamConnection)
Declaration
public void Disconnect(NetworkStreamConnection connection)
Parameters
Exceptions
Dispose()
Dispose all the registered drivers instances and their allocated resources.
Declaration
ForEachDriver(DriverVisitor)
Invoke the delegate on all registered drivers.
Declaration
[Obsolete("The ForEachDriver has been deprecated. Please always iterate over the driver using a for loop, using the FirstDriver and LastDriver ids instead.")]
public void ForEachDriver(NetworkDriverStore.DriverVisitor visitor)
Parameters
GetConnectionState(NetworkStreamConnection)
Declaration
public NetworkConnection.State GetConnectionState(NetworkStreamConnection connection)
Parameters
Returns
Type |
Description |
NetworkConnection.State |
|
Exceptions
GetDriverInstance(int)
Declaration
[Obsolete("Prefer GetDriverInstanceRW or GetDriverInstanceRO to avoid copying.", false)]
public readonly ref 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
Exceptions
GetDriverInstanceRO(int)
Declaration
public ref readonly NetworkDriverStore.NetworkDriverInstance GetDriverInstanceRO(int driverId)
Parameters
Type |
Name |
Description |
int |
driverId |
|
Returns
Exceptions
GetDriverInstanceRW(int)
Declaration
public ref NetworkDriverStore.NetworkDriverInstance GetDriverInstanceRW(int driverId)
Parameters
Type |
Name |
Description |
int |
driverId |
|
Returns
Exceptions
GetDriverRO(int)
Retrieve a Read-Only reference to the Unity.Networking.Transport.NetworkDriver for the given driverId.
Declaration
public ref readonly NetworkDriver GetDriverRO(int driverId)
Parameters
Type |
Name |
Description |
int |
driverId |
|
Returns
Type |
Description |
NetworkDriver |
|
Exceptions
GetDriverRW(int)
Retrieve a ReadWrite reference to the Unity.Networking.Transport.NetworkDriver for the given driverId.
Declaration
public ref NetworkDriver GetDriverRW(int driverId)
Parameters
Type |
Name |
Description |
int |
driverId |
|
Returns
Type |
Description |
NetworkDriver |
|
Exceptions
GetDriverType(int)
Return the transport type used by the registered driver.
Declaration
public TransportType GetDriverType(int driverId)
Parameters
Type |
Name |
Description |
int |
driverId |
|
Returns
Exceptions
GetNetworkDriver(int)
Return the Unity.Networking.Transport.NetworkDriver with the given driverId.
Declaration
[Obsolete("Prefer GetDriverRW or GetDriverRO to avoid copying.", false)]
public readonly NetworkDriver GetNetworkDriver(int driverId)
Parameters
Type |
Name |
Description |
int |
driverId |
|
Returns
Type |
Description |
NetworkDriver |
|
Exceptions
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
Returns
Type |
Description |
int |
The assigned driver id
|
Exceptions
ScheduleFlushSendAllDrivers(JobHandle)
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.
|