Search Results for

    Show / Hide Table of Contents

    Class WebSocketClient

    The default, native-based WebSocket client implementation.

    Inheritance
    System.Object
    WebSocketClient
    Implements
    IWebSocketClient
    Namespace: DisCatSharp.Net.WebSocket
    Assembly: DisCatSharp.dll
    Syntax
    public class WebSocketClient : IWebSocketClient, IDisposable

    Properties

    | Improve this Doc View Source

    DefaultHeaders

    Gets the collection of default headers to send when connecting to the remote endpoint.

    Declaration
    public IReadOnlyDictionary<string, string> DefaultHeaders { get; }
    Property Value
    Type Description
    System.Collections.Generic.IReadOnlyDictionary<System.String, System.String>
    | Improve this Doc View Source

    Proxy

    Gets the proxy settings for this client.

    Declaration
    public IWebProxy Proxy { get; }
    Property Value
    Type Description
    System.Net.IWebProxy

    Methods

    | Improve this Doc View Source

    AddDefaultHeader(String, String)

    Adds a header to the default header collection.

    Declaration
    public bool AddDefaultHeader(string name, string value)
    Parameters
    Type Name Description
    System.String name

    Name of the header to add.

    System.String value

    Value of the header to add.

    Returns
    Type Description
    System.Boolean

    Whether the operation succeeded.

    | Improve this Doc View Source

    ConnectAsync(Uri)

    Connects to a specified remote WebSocket endpoint.

    Declaration
    public async Task ConnectAsync(Uri uri)
    Parameters
    Type Name Description
    System.Uri uri

    The URI of the WebSocket endpoint.

    Returns
    Type Description
    System.Threading.Tasks.Task
    | Improve this Doc View Source

    CreateNew(IWebProxy, IServiceProvider)

    Creates a new instance of WebSocketClient.

    Declaration
    public static IWebSocketClient CreateNew(IWebProxy proxy, IServiceProvider provider)
    Parameters
    Type Name Description
    System.Net.IWebProxy proxy

    Proxy to use for this client instance.

    System.IServiceProvider provider

    Service provider.

    Returns
    Type Description
    IWebSocketClient

    An instance of WebSocketClient.

    | Improve this Doc View Source

    DisconnectAsync(Int32, String)

    Disconnects the WebSocket connection.

    Declaration
    public async Task DisconnectAsync(int code = 1000, string message = "")
    Parameters
    Type Name Description
    System.Int32 code

    The code

    System.String message

    The message

    Returns
    Type Description
    System.Threading.Tasks.Task
    | Improve this Doc View Source

    Dispose()

    Disposes of resources used by this WebSocket client instance.

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    RemoveDefaultHeader(String)

    Removes a header from the default header collection.

    Declaration
    public bool RemoveDefaultHeader(string name)
    Parameters
    Type Name Description
    System.String name

    Name of the header to remove.

    Returns
    Type Description
    System.Boolean

    Whether the operation succeeded.

    | Improve this Doc View Source

    SendMessageAsync(String)

    Send a message to the WebSocket server.

    Declaration
    public async Task SendMessageAsync(string message)
    Parameters
    Type Name Description
    System.String message

    The message to send.

    Returns
    Type Description
    System.Threading.Tasks.Task

    Events

    | Improve this Doc View Source

    Connected

    Triggered when the client connects successfully.

    Declaration
    public event AsyncEventHandler<IWebSocketClient, SocketEventArgs> Connected
    Event Type
    Type Description
    AsyncEventHandler<IWebSocketClient, SocketEventArgs>
    | Improve this Doc View Source

    Disconnected

    Triggered when the client is disconnected.

    Declaration
    public event AsyncEventHandler<IWebSocketClient, SocketCloseEventArgs> Disconnected
    Event Type
    Type Description
    AsyncEventHandler<IWebSocketClient, SocketCloseEventArgs>
    | Improve this Doc View Source

    ExceptionThrown

    Triggered when an error occurs in the client.

    Declaration
    public event AsyncEventHandler<IWebSocketClient, SocketErrorEventArgs> ExceptionThrown
    Event Type
    Type Description
    AsyncEventHandler<IWebSocketClient, SocketErrorEventArgs>
    | Improve this Doc View Source

    MessageReceived

    Triggered when the client receives a message from the remote party.

    Declaration
    public event AsyncEventHandler<IWebSocketClient, SocketMessageEventArgs> MessageReceived
    Event Type
    Type Description
    AsyncEventHandler<IWebSocketClient, SocketMessageEventArgs>

    Implements

    IWebSocketClient

    Extension Methods

    ReflectionUtilities.ToDictionary<T>(T)
    • Improve this Doc
    • View Source
    In This Article
    Back to top © 2021-2022 Aiko IT Systems