docs.unity3d.com
    Show / Hide Table of Contents

    Struct WebSocketNetworkInterface

    Interface used to establish WebSocket connections.

    Inherited Members
    ValueType.Equals(Object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: Unity.Networking.Transport
    Syntax
    [BurstCompile]
    public struct WebSocketNetworkInterface : INetworkInterface, IDisposable
    Examples

    This code creates a NetworkDriver that will use WebSocket connections, instead of the default UDP-based connections:

        var driver = NetworkDriver.Create(new WebSocketNetworkInterface());
        // Can then be used just like a UDP-based driver.

    Properties

    LocalEndpoint

    Gets the local endpoint that the interface will use to communicate on the network. This call only makes sense after Bind(NetworkEndpoint) has already been called, and represents the endpoint the interface is actually bound to. This property serves the same purpose as getsockname in the BSD socket world.

    Declaration
    public readonly NetworkEndpoint LocalEndpoint { get; }
    Property Value
    Type Description
    NetworkEndpoint

    Local endpoint.

    Implements
    INetworkInterface.LocalEndpoint

    Methods

    Bind(NetworkEndpoint)

    Binds the network interface to an endpoint. This is meant to act the same way as the bind call in the BSD socket world. One way to see it is that it "attaches" the network interface to a specific local address on the machine.

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

    Endpoint to bind to.

    Returns
    Type Description
    Int32

    0 on success, a negative number on error.

    Implements
    INetworkInterface.Bind(NetworkEndpoint)

    Dispose()

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()

    Initialize(ref NetworkSettings, ref Int32)

    Initialize the network interface with the given settings.

    Declaration
    public int Initialize(ref NetworkSettings settings, ref int packetPadding)
    Parameters
    Type Name Description
    NetworkSettings settings

    Configuration settings provided to the driver.

    Int32 packetPadding

    Return value parameter for how much padding the interface adds to packets. Note that this parameter is only concerned about padding that would be added directly in the packets stored in the send and receive queues, not to padding that would be added by lower levels of the network stack (e.g. IP headers).

    Returns
    Type Description
    Int32

    0 on success, a negative number on error.

    Implements
    INetworkInterface.Initialize(ref NetworkSettings, ref Int32)

    Listen()

    Start listening for incoming connections. Unlike Bind(NetworkEndpoint) which will always be called on clients and servers, this is only meant to be called on servers.

    Declaration
    public int Listen()
    Returns
    Type Description
    Int32

    0 on success, a negative number on error.

    Implements
    INetworkInterface.Listen()

    ScheduleReceive(ref ReceiveJobArguments, JobHandle)

    Schedule a receive job. This job's responsibility is to read data from the network and enqueue it in ReceiveQueue.

    Declaration
    public JobHandle ScheduleReceive(ref ReceiveJobArguments arguments, JobHandle dep)
    Parameters
    Type Name Description
    ReceiveJobArguments arguments

    Arguments to be passed to the receive job.

    JobHandle dep

    Handle to any dependency the receive job has (use default if none).

    Returns
    Type Description
    JobHandle

    Handle to the newly-schedule job.

    Implements
    INetworkInterface.ScheduleReceive(ref ReceiveJobArguments, JobHandle)

    ScheduleSend(ref SendJobArguments, JobHandle)

    Schedule a send job. This job's responsibility is to flush any data stored in SendQueue to the network.

    Declaration
    public JobHandle ScheduleSend(ref SendJobArguments arguments, JobHandle dep)
    Parameters
    Type Name Description
    SendJobArguments arguments

    Arguments to be passed to the send job.

    JobHandle dep

    Handle to any dependency the send job has (use default if none).

    Returns
    Type Description
    JobHandle

    Handle to the newly-schedule job.

    Implements
    INetworkInterface.ScheduleSend(ref SendJobArguments, JobHandle)

    Extension Methods

    ManagedNetworkInterfaceExtensions.WrapToUnmanaged<T>(T)
    In This Article
    • Properties
      • LocalEndpoint
    • Methods
      • Bind(NetworkEndpoint)
      • Dispose()
      • Initialize(ref NetworkSettings, ref Int32)
      • Listen()
      • ScheduleReceive(ref ReceiveJobArguments, JobHandle)
      • ScheduleSend(ref SendJobArguments, JobHandle)
    • Extension Methods
    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