Struct NetworkDriver | Unity Transport | 0.6.0-preview.7
docs.unity3d.com
    Show / Hide Table of Contents

    Struct NetworkDriver

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

    Basic usage:

    var driver = new NetworkDriver.Create();
    Namespace: Unity.Networking.Transport
    Syntax
    public struct NetworkDriver : IDisposable

    Constructors

    NetworkDriver(INetworkInterface, INetworkParameter[])

    Constructor for NetworkDriver.

    Declaration
    public NetworkDriver(INetworkInterface netIf, params INetworkParameter[] param)
    Parameters
    Type Name Description
    INetworkInterface netIf
    INetworkParameter[] param

    An array of INetworkParameter. There are currently only two INetworkParameter, the NetworkDataStreamParameter and the NetworkConfigParameter.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the value for NetworkDataStreamParameter.size is smaller then zero.

    Properties

    IsCreated

    Declaration
    public bool IsCreated { get; }
    Property Value
    Type Description
    Boolean

    LastUpdateTime

    Declaration
    public long LastUpdateTime { get; }
    Property Value
    Type Description
    Int64

    Listening

    Declaration
    public bool Listening { get; }
    Property Value
    Type Description
    Boolean

    ReceiveErrorCode

    Declaration
    public int ReceiveErrorCode { get; }
    Property Value
    Type Description
    Int32

    Methods

    AbortSend(DataStreamWriter)

    Declaration
    public void AbortSend(DataStreamWriter writer)
    Parameters
    Type Name Description
    DataStreamWriter writer

    Accept()

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

    Declaration
    public NetworkConnection Accept()
    Returns
    Type Description
    NetworkConnection

    If 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
    Type Name Description
    NetworkConnection id
    DataStreamWriter writer
    Int32 requiredPayloadSize
    Returns
    Type Description
    Int32

    BeginSend(NetworkPipeline, NetworkConnection, out DataStreamWriter, Int32)

    Declaration
    public int BeginSend(NetworkPipeline pipe, NetworkConnection id, out DataStreamWriter writer, int requiredPayloadSize = 0)
    Parameters
    Type Name Description
    NetworkPipeline pipe
    NetworkConnection id
    DataStreamWriter writer
    Int32 requiredPayloadSize
    Returns
    Type Description
    Int32

    Bind(NetworkEndPoint)

    Bind the driver to a endpoint.

    Declaration
    public int Bind(NetworkEndPoint endpoint)
    Parameters
    Type Name Description
    NetworkEndPoint endpoint

    The endpoint to bind to.

    Returns
    Type Description
    Int32

    Returns 0 on success. And a negative value if a error occured.

    Exceptions
    Type Condition
    InvalidOperationException

    If the driver is not created properly

    InvalidOperationException

    If bind is called more then once on the driver

    InvalidOperationException

    If 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
    Type Name Description
    NetworkEndPoint endpoint
    Returns
    Type Description
    NetworkConnection

    If connect fails it returns a default NetworkConnection.

    Exceptions
    Type Condition
    InvalidOperationException

    If the driver is not created properly

    Create(INetworkParameter[])

    Helper function for creating a NetworkDriver.

    Declaration
    public static NetworkDriver Create(params INetworkParameter[] param)
    Parameters
    Type Name Description
    INetworkParameter[] param

    An optional array of INetworkParameter. There are currently only two INetworkParameter, the NetworkDataStreamParameter and the NetworkConfigParameter.

    Returns
    Type Description
    NetworkDriver
    Exceptions
    Type Condition
    InvalidOperationException

    CreatePipeline(Type[])

    Create a new pipeline.

    Declaration
    public NetworkPipeline CreatePipeline(params Type[] stages)
    Parameters
    Type Name Description
    Type[] stages

    An array of stages the pipeline should contain.

    Returns
    Type Description
    NetworkPipeline
    Exceptions
    Type Condition
    InvalidOperationException

    If the driver is not created properly

    InvalidOperationException

    A connection has already been established

    Disconnect(NetworkConnection)

    Disconnects a NetworkConnection

    Declaration
    public int Disconnect(NetworkConnection id)
    Parameters
    Type Name Description
    NetworkConnection id

    The NetworkConnection we want to Disconnect.

    Returns
    Type Description
    Int32

    Return 0 on success.

    Dispose()

    Declaration
    public void Dispose()

    EndSend(DataStreamWriter)

    Declaration
    public int EndSend(DataStreamWriter writer)
    Parameters
    Type Name Description
    DataStreamWriter writer
    Returns
    Type Description
    Int32

    GetConnectionState(NetworkConnection)

    Declaration
    public NetworkConnection.State GetConnectionState(NetworkConnection con)
    Parameters
    Type Name Description
    NetworkConnection con
    Returns
    Type Description
    NetworkConnection.State

    GetEventQueueSizeForConnection(NetworkConnection)

    Returns the size of the eventqueue for a specific connection

    Declaration
    public int GetEventQueueSizeForConnection(NetworkConnection connectionId)
    Parameters
    Type Name Description
    NetworkConnection connectionId
    Returns
    Type Description
    Int32

    If 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
    Type Name Description
    NetworkPipeline pipeline
    NetworkPipelineStageId stageId
    NetworkConnection connection
    NativeArray<Byte> readProcessingBuffer
    NativeArray<Byte> writeProcessingBuffer
    NativeArray<Byte> sharedBuffer
    Exceptions
    Type Condition
    InvalidOperationException

    If the the connection is invalid.

    Listen()

    Set the driver to Listen for incomming connections

    Declaration
    public int Listen()
    Returns
    Type Description
    Int32

    Returns 0 on success.

    Exceptions
    Type Condition
    InvalidOperationException

    If the driver is not created properly

    InvalidOperationException

    If listen is called more then once on the driver

    InvalidOperationException

    If bind has not been called before calling Listen.

    LocalEndPoint()

    Declaration
    public NetworkEndPoint LocalEndPoint()
    Returns
    Type Description
    NetworkEndPoint

    MaxHeaderSize(NetworkPipeline)

    Declaration
    public int MaxHeaderSize(NetworkPipeline pipe)
    Parameters
    Type Name Description
    NetworkPipeline pipe
    Returns
    Type Description
    Int32

    PopEvent(out NetworkConnection, out DataStreamReader)

    Declaration
    public NetworkEvent.Type PopEvent(out NetworkConnection con, out DataStreamReader reader)
    Parameters
    Type Name Description
    NetworkConnection con
    DataStreamReader reader
    Returns
    Type Description
    NetworkEvent.Type

    PopEventForConnection(NetworkConnection, out DataStreamReader)

    Declaration
    public NetworkEvent.Type PopEventForConnection(NetworkConnection connectionId, out DataStreamReader reader)
    Parameters
    Type Name Description
    NetworkConnection connectionId
    DataStreamReader reader
    Returns
    Type Description
    NetworkEvent.Type

    RemoteEndPoint(NetworkConnection)

    Declaration
    public NetworkEndPoint RemoteEndPoint(NetworkConnection id)
    Parameters
    Type Name Description
    NetworkConnection id
    Returns
    Type Description
    NetworkEndPoint

    ScheduleFlushSend(JobHandle)

    Declaration
    public JobHandle ScheduleFlushSend(JobHandle dep)
    Parameters
    Type Name Description
    JobHandle dep
    Returns
    Type Description
    JobHandle

    ScheduleUpdate(JobHandle)

    Declaration
    public JobHandle ScheduleUpdate(JobHandle dep = default(JobHandle))
    Parameters
    Type Name Description
    JobHandle dep
    Returns
    Type Description
    JobHandle

    ToConcurrent()

    Create a Concurrent Copy of the NetworkDriver.

    Declaration
    public NetworkDriver.Concurrent ToConcurrent()
    Returns
    Type Description
    NetworkDriver.Concurrent
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023