Wolfringo Wolfringo
Wolfringo Wolfringo
Wolfringo (c) 2020 TehGM
DocFX, DiscordFX theme.
Search Results for

    Class WolfClientExtensions

    Extension methods for IWolfClient.

    Inheritance
    System.Object
    WolfClientExtensions
    Namespace: TehGM.Wolfringo
    Assembly: Wolfringo.Core.dll
    Syntax
    public static class WolfClientExtensions

    Methods

    | Improve this Doc View Source

    AddMessageListener<T>(IWolfClient, Action<T>)

    Adds event listener, invoking when received message is of correct type.

    Declaration
    public static void AddMessageListener<T>(this IWolfClient client, Action<T> callback)
        where T : IWolfMessage
    Parameters
    Type Name Description
    IWolfClient client

    Client to listen to events of.

    System.Action<T> callback

    Callback to invoke on event.

    Type Parameters
    Name Description
    T

    Type of received message to invoke callback for.

    | Improve this Doc View Source

    AddMessageListener<T>(IWolfClient, String, Action<T>)

    Adds event listener, invoking when received message is of correct type and has matching command.

    Declaration
    public static void AddMessageListener<T>(this IWolfClient client, string command, Action<T> callback)
        where T : IWolfMessage
    Parameters
    Type Name Description
    IWolfClient client

    Client to listen to events of.

    System.String command

    Message command that has to match for callback to be invoked.

    System.Action<T> callback

    Callback to invoke on event.

    Type Parameters
    Name Description
    T

    Type of received message to invoke callback for.

    | Improve this Doc View Source

    RemoveMessageListener<T>(IWolfClient, Action<T>)

    Removes event listener.

    Declaration
    public static void RemoveMessageListener<T>(this IWolfClient client, Action<T> callback)
        where T : IWolfMessage
    Parameters
    Type Name Description
    IWolfClient client

    Client to remove events listener from.

    System.Action<T> callback

    Callback to remove.

    Type Parameters
    Name Description
    T
    Remarks

    Provided type T must be the same as the type used when adding the listener.

    | Improve this Doc View Source

    SendAsync(IWolfClient, IWolfMessage, CancellationToken)

    Sends message, and waits for response from the server.

    Declaration
    public static Task<WolfResponse> SendAsync(this IWolfClient client, IWolfMessage message, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IWolfClient client

    Client to send the message with.

    IWolfMessage message

    Message to send.

    System.Threading.CancellationToken cancellationToken

    Cancellation token that can be used for Task cancellation.

    Returns
    Type Description
    System.Threading.Tasks.Task<WolfResponse>

    Sending response.

    Remarks

    If client uses ResponseTypeResolver, the type of response provided with ResponseTypeAttribute on message will be used for deserialization.
    Otherwise, response will be deserialized asWolfResponse.

    Exceptions
    Type Condition
    MessageSendingException

    Server responded with error.