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.
|
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.