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: MLAPI.dll#
Syntax#
public struct NetworkDriver : IDisposable

Constructors#

NetworkDriver(INetworkInterface, INetworkParameter[])#

Constructor for NetworkDriver.

Declaration#

public NetworkDriver(INetworkInterface netIf, params INetworkParameter[] param)

Parameters#

TypeNameDescription
INetworkInterfacenetIf
INetworkParameter[]paramAn array of INetworkParameter. There are currently only two INetworkParameter, the NetworkDataStreamParameter and the NetworkConfigParameter.

Exceptions#

TypeCondition
System.ArgumentExceptionThrown if the value for NetworkDataStreamParameter.size is smaller then zero.

Properties#

IsCreated#

Declaration#

public bool IsCreated { get; }

Property Value#

TypeDescription
System.Boolean

LastUpdateTime#

Declaration#

public 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

Methods#

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.

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(INetworkParameter[])#

Helper function for creating a NetworkDriver.

Declaration#

public static NetworkDriver Create(params INetworkParameter[] param)

Parameters#

TypeNameDescription
INetworkParameter[]paramAn optional array of INetworkParameter. There are currently only two INetworkParameter, the NetworkDataStreamParameter and the NetworkConfigParameter.

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
Unity.Collections.NativeArray<System.Byte>readProcessingBuffer
Unity.Collections.NativeArray<System.Byte>writeProcessingBuffer
Unity.Collections.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

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 dep)

Parameters#

TypeNameDescription
Unity.Jobs.JobHandledep

Returns#

TypeDescription
Unity.Jobs.JobHandle

ScheduleUpdate(JobHandle)#

Declaration#

public JobHandle ScheduleUpdate(JobHandle dep = default(JobHandle))

Parameters#

TypeNameDescription
Unity.Jobs.JobHandledep

Returns#

TypeDescription
Unity.Jobs.JobHandle

ToConcurrent()#

Create a Concurrent Copy of the NetworkDriver.

Declaration#

public NetworkDriver.Concurrent ToConcurrent()

Returns#

TypeDescription
NetworkDriver.Concurrent

Implements#

System.IDisposable