Skip to main content

Unity.Networking.Transport.NetworkDriver

The NetworkDriver is an implementation of Virtual Connections over any transport.

Basic usage:

var driver = new NetworkDriver.Create();
Implements#

System.IDisposable

Inherited Members#

ValueType.Equals(Object)

ValueType.GetHashCode()

ValueType.ToString()

Object.Equals(Object, Object)

Object.GetType()

Object.ReferenceEquals(Object, Object)

Namespace: System.Dynamic.ExpandoObject#
Assembly: transport.dll#
Syntax#
public struct NetworkDriver : IDisposable

NetworkDriver(INetworkInterface)#

Declaration#

public NetworkDriver(INetworkInterface netIf)

Parameters#

TypeNameDescription
INetworkInterfacenetIf

NetworkDriver(INetworkInterface, INetworkParameter[])#

Declaration#

[Obsolete("Use NetworkDriver(INetworkInterface, NetworkSettings) instead", false)]
public NetworkDriver(INetworkInterface netIf, params INetworkParameter[] param)

Parameters#

TypeNameDescription
INetworkInterfacenetIf
INetworkParameter[]param

NetworkDriver(INetworkInterface, NetworkSettings)#

Declaration#

public NetworkDriver(INetworkInterface netIf, NetworkSettings settings)

Parameters#

TypeNameDescription
INetworkInterfacenetIf
NetworkSettingssettings

#

Bound#

Declaration#

public readonly bool Bound { get; }

Property Value#

TypeDescription
System.Boolean

IsCreated#

Declaration#

public readonly bool IsCreated { get; }

Property Value#

TypeDescription
System.Boolean

LastUpdateTime#

Declaration#

public readonly long LastUpdateTime { get; }

Property Value#

TypeDescription
System.Int64

Listening#

Declaration#

public bool Listening { get; }

Property Value#

TypeDescription
System.Boolean

ReceiveErrorCode#

Declaration#

public int ReceiveErrorCode { get; }

Property Value#

TypeDescription
System.Int32

#

AbortSend(DataStreamWriter)#

Declaration#

public void AbortSend(DataStreamWriter writer)

Parameters#

TypeNameDescription
DataStreamWriterwriter

Accept()#

Checks to see if there are any new connections to Accept.

Declaration#

public NetworkConnection Accept()

Returns#

TypeDescription
NetworkConnectionIf accept fails it returnes a default NetworkConnection.

AllocateMemory(ref Int32)#

Allocates temporary memory in NetworkDriver's data stream. You don't need to deallocate it If you need to call this function several times - use PinMemoryTillUpdate(Int32) to move 'head'

Declaration#

public IntPtr AllocateMemory(ref int dataLen)

Parameters#

TypeNameDescription
System.Int32dataLenSize of memory to allocate in bytes. Must be > 0

Returns#

TypeDescription
System.IntPtrPointer to allocated memory or IntPtr.Zero if there is no space left (this function doesn't set ReceiveErrorCode! caller should decide if this is Out of memory or something else)

BeginSend(NetworkConnection, out DataStreamWriter, Int32)#

Declaration#

public int BeginSend(NetworkConnection id, out DataStreamWriter writer, int requiredPayloadSize = 0)

Parameters#

TypeNameDescription
NetworkConnectionid
DataStreamWriterwriter
System.Int32requiredPayloadSize

Returns#

TypeDescription
System.Int32

BeginSend(NetworkPipeline, NetworkConnection, out DataStreamWriter, Int32)#

Declaration#

public int BeginSend(NetworkPipeline pipe, NetworkConnection id, out DataStreamWriter writer, int requiredPayloadSize = 0)

Parameters#

TypeNameDescription
NetworkPipelinepipe
NetworkConnectionid
DataStreamWriterwriter
System.Int32requiredPayloadSize

Returns#

TypeDescription
System.Int32

Bind(NetworkEndPoint)#

Bind the driver to a endpoint.

Declaration#

public int Bind(NetworkEndPoint endpoint)

Parameters#

TypeNameDescription
NetworkEndPointendpointThe endpoint to bind to.

Returns#

TypeDescription
System.Int32Returns 0 on success. And a negative value if a error occured.

Exceptions#

TypeCondition
System.InvalidOperationExceptionIf the driver is not created properly
System.InvalidOperationExceptionIf bind is called more then once on the driver
System.InvalidOperationExceptionIf bind is called after a connection has already been established

Connect(NetworkEndPoint)#

Connects the driver to a endpoint

Declaration#

public NetworkConnection Connect(NetworkEndPoint endpoint)

Parameters#

TypeNameDescription
NetworkEndPointendpoint

Returns#

TypeDescription
NetworkConnectionIf connect fails it returns a default NetworkConnection.

Exceptions#

TypeCondition
System.InvalidOperationExceptionIf the driver is not created properly

Create()#

Declaration#

public static NetworkDriver Create()

Returns#

TypeDescription
NetworkDriver

Create(INetworkParameter[])#

Declaration#

[Obsolete("Use Create(NetworkSettings) instead", false)]
public static NetworkDriver Create(params INetworkParameter[] param)

Parameters#

TypeNameDescription
INetworkParameter[]param

Returns#

TypeDescription
NetworkDriver

Create(NetworkSettings)#

Helper function for creating a NetworkDriver.

Declaration#

public static NetworkDriver Create(NetworkSettings settings)

Parameters#

TypeNameDescription
NetworkSettingssettings

Returns#

TypeDescription
NetworkDriver

Exceptions#

TypeCondition
System.InvalidOperationException

CreatePipeline(Type[])#

Create a new pipeline.

Declaration#

public NetworkPipeline CreatePipeline(params Type[] stages)

Parameters#

TypeNameDescription
System.Type[]stagesAn array of stages the pipeline should contain.

Returns#

TypeDescription
NetworkPipeline

Exceptions#

TypeCondition
System.InvalidOperationExceptionIf the driver is not created properly
System.InvalidOperationExceptionA connection has already been established

Disconnect(NetworkConnection)#

Disconnects a NetworkConnection

Declaration#

public int Disconnect(NetworkConnection id)

Parameters#

TypeNameDescription
NetworkConnectionidThe NetworkConnection we want to Disconnect.

Returns#

TypeDescription
System.Int32Return 0 on success.

Dispose()#

Declaration#

public void Dispose()

EndSend(DataStreamWriter)#

Declaration#

public int EndSend(DataStreamWriter writer)

Parameters#

TypeNameDescription
DataStreamWriterwriter

Returns#

TypeDescription
System.Int32

GetConnectionState(NetworkConnection)#

Declaration#

public NetworkConnection.State GetConnectionState(NetworkConnection con)

Parameters#

TypeNameDescription
NetworkConnectioncon

Returns#

TypeDescription
NetworkConnection.State

GetEventQueueSizeForConnection(NetworkConnection)#

Returns the size of the EventQueue for a specific connection

Declaration#

public int GetEventQueueSizeForConnection(NetworkConnection connectionId)

Parameters#

TypeNameDescription
NetworkConnectionconnectionId

Returns#

TypeDescription
System.Int32If the connection is valid it returns the size of the event queue otherwise it returns 0.

GetPipelineBuffers(NetworkPipeline, NetworkPipelineStageId, NetworkConnection, out NativeArray<Byte>, out NativeArray<Byte>, out NativeArray<Byte>))#

Returns the PipelineBuffers for a specific pipeline and stage.

Declaration#

public void GetPipelineBuffers(NetworkPipeline pipeline, NetworkPipelineStageId stageId, NetworkConnection connection, out NativeArray<byte> readProcessingBuffer, out NativeArray<byte> writeProcessingBuffer, out NativeArray<byte> sharedBuffer)

Parameters#

TypeNameDescription
NetworkPipelinepipeline
NetworkPipelineStageIdstageId
NetworkConnectionconnection
NativeArray<System.Byte>readProcessingBuffer
NativeArray<System.Byte>writeProcessingBuffer
NativeArray<System.Byte>sharedBuffer

Exceptions#

TypeCondition
System.InvalidOperationExceptionIf the the connection is invalid.

Listen()#

Set the driver to Listen for incomming connections

Declaration#

public int Listen()

Returns#

TypeDescription
System.Int32Returns 0 on success.

Exceptions#

TypeCondition
System.InvalidOperationExceptionIf the driver is not created properly
System.InvalidOperationExceptionIf listen is called more then once on the driver
System.InvalidOperationExceptionIf bind has not been called before calling Listen.

LocalEndPoint()#

Declaration#

public NetworkEndPoint LocalEndPoint()

Returns#

TypeDescription
NetworkEndPoint

MaxHeaderSize(NetworkPipeline)#

Declaration#

public int MaxHeaderSize(NetworkPipeline pipe)

Parameters#

TypeNameDescription
NetworkPipelinepipe

Returns#

TypeDescription
System.Int32

PinMemoryTillUpdate(Int32)#

Moves 'head' of allocator for 'length' bytes. Use this to 'pin' memory in till the next update. If you don't call it - it is 'pinned' till the next call to AllocateMemory(ref Int32) Means every time you call AllocateMemory(ref Int32) without PinMemoryTillUpdate(Int32) memory is overriden

Declaration#

public int PinMemoryTillUpdate(int length)

Parameters#

TypeNameDescription
System.Int32lengthBytes to move

Returns#

TypeDescription
System.Int32Returns head of pinned memory

PopEvent(out NetworkConnection, out DataStreamReader)#

Declaration#

public NetworkEvent.Type PopEvent(out NetworkConnection con, out DataStreamReader reader)

Parameters#

TypeNameDescription
NetworkConnectioncon
DataStreamReaderreader

Returns#

TypeDescription
NetworkEvent.Type

PopEvent(out NetworkConnection, out DataStreamReader, out NetworkPipeline)#

Declaration#

public NetworkEvent.Type PopEvent(out NetworkConnection con, out DataStreamReader reader, out NetworkPipeline pipeline)

Parameters#

TypeNameDescription
NetworkConnectioncon
DataStreamReaderreader
NetworkPipelinepipeline

Returns#

TypeDescription
NetworkEvent.Type

PopEventForConnection(NetworkConnection, out DataStreamReader)#

Declaration#

public NetworkEvent.Type PopEventForConnection(NetworkConnection connectionId, out DataStreamReader reader)

Parameters#

TypeNameDescription
NetworkConnectionconnectionId
DataStreamReaderreader

Returns#

TypeDescription
NetworkEvent.Type

PopEventForConnection(NetworkConnection, out DataStreamReader, out NetworkPipeline)#

Declaration#

public NetworkEvent.Type PopEventForConnection(NetworkConnection connectionId, out DataStreamReader reader, out NetworkPipeline pipeline)

Parameters#

TypeNameDescription
NetworkConnectionconnectionId
DataStreamReaderreader
NetworkPipelinepipeline

Returns#

TypeDescription
NetworkEvent.Type

RemoteEndPoint(NetworkConnection)#

Declaration#

public NetworkEndPoint RemoteEndPoint(NetworkConnection id)

Parameters#

TypeNameDescription
NetworkConnectionid

Returns#

TypeDescription
NetworkEndPoint

ScheduleFlushSend(JobHandle)#

Declaration#

public JobHandle ScheduleFlushSend(JobHandle dependency)

Parameters#

TypeNameDescription
JobHandledependency

Returns#

TypeDescription
JobHandle

ScheduleUpdate(JobHandle)#

Declaration#

public JobHandle ScheduleUpdate(JobHandle dependency = null)

Parameters#

TypeNameDescription
JobHandledependency

Returns#

TypeDescription
JobHandle

ToConcurrent()#

Create a Concurrent Copy of the NetworkDriver.

Declaration#

public NetworkDriver.Concurrent ToConcurrent()

Returns#

TypeDescription
NetworkDriver.Concurrent

Implements#

System.IDisposable