Class InteractiveExtensions
Set of helper methods to make work with IWolfClient combined with IInteractiveListener<T> easier.
Namespace: TehGM.Wolfringo
Assembly: Wolfringo.Utilities.Interactive.dll
Syntax
public static class InteractiveExtensions
Methods
| Improve this Doc View SourceAwaitNextAsync<T>(IWolfClient, Func<T, Boolean>, CancellationToken)
Awaits next message of given type that matches specified conditions.
Declaration
public static Task<T> AwaitNextAsync<T>(this IWolfClient client, Func<T, bool> conditions, CancellationToken cancellationToken = default(CancellationToken))
where T : IWolfMessage
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | Client to await message from. |
Func<T, Boolean> | conditions | Conditions that received message needs to match. |
CancellationToken | cancellationToken | Token that can cancel the awaiting. |
Returns
Type | Description |
---|---|
Task<T> | Next message. |
Type Parameters
Name | Description |
---|---|
T |
See Also
AwaitNextAsync<T>(IWolfClient, Func<T, Boolean>, TimeSpan, CancellationToken)
Awaits next message of given type that matches specified conditions.
Declaration
public static async Task<T> AwaitNextAsync<T>(this IWolfClient client, Func<T, bool> conditions, TimeSpan timeout, CancellationToken cancellationToken = default(CancellationToken))
where T : IWolfMessage
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | Client to await message from. |
Func<T, Boolean> | conditions | Conditions that received message needs to match. |
TimeSpan | timeout | Timeout after which waiting will be aborted. |
CancellationToken | cancellationToken | Token that can cancel the awaiting. |
Returns
Type | Description |
---|---|
Task<T> | Next message. |
Type Parameters
Name | Description |
---|---|
T |
Remarks
This method actually uses a CancellationTokenSource under the hood, and simply cancels the token
after specified timeout
.
If the task is cancelled a default (most likely null> value will be returned. TaskCanceledException will not be thrown.
See Also
AwaitNextGroupByUserAsync(IWolfClient, UInt32, UInt32, CancellationToken)
Awaits next chat message in specified group from specified user.
Declaration
public static Task<ChatMessage> AwaitNextGroupByUserAsync(this IWolfClient client, uint userID, uint groupID, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | Client to await message from. |
UInt32 | userID | User ID to await the message from. |
UInt32 | groupID | Group ID to await the message from. |
CancellationToken | cancellationToken | Token that can cancel the awaiting. |
Returns
Type | Description |
---|---|
Task<ChatMessage> | Next message. |
See Also
AwaitNextGroupByUserAsync(IWolfClient, UInt32, UInt32, TimeSpan, CancellationToken)
Awaits next chat message in specified group from specified user.
Declaration
public static Task<ChatMessage> AwaitNextGroupByUserAsync(this IWolfClient client, uint userID, uint groupID, TimeSpan timeout, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | Client to await message from. |
UInt32 | userID | User ID to await the message from. |
UInt32 | groupID | Group ID to await the message from. |
TimeSpan | timeout | Timeout after which waiting will be aborted. |
CancellationToken | cancellationToken | Token that can cancel the awaiting. |
Returns
Type | Description |
---|---|
Task<ChatMessage> | Next message. |
Remarks
This method actually uses a CancellationTokenSource under the hood, and simply cancels the token
after specified timeout
.
If the task is cancelled a default (most likely null> value will be returned. TaskCanceledException will not be thrown.
See Also
AwaitNextInGroupAsync(IWolfClient, UInt32, CancellationToken)
Awaits next chat message in specified group.
Declaration
public static Task<ChatMessage> AwaitNextInGroupAsync(this IWolfClient client, uint groupID, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | Client to await message from. |
UInt32 | groupID | Group ID to await the message from. |
CancellationToken | cancellationToken | Token that can cancel the awaiting. |
Returns
Type | Description |
---|---|
Task<ChatMessage> | Next message. |
See Also
AwaitNextInGroupAsync(IWolfClient, UInt32, TimeSpan, CancellationToken)
Awaits next chat message in specified group.
Declaration
public static Task<ChatMessage> AwaitNextInGroupAsync(this IWolfClient client, uint groupID, TimeSpan timeout, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | Client to await message from. |
UInt32 | groupID | Group ID to await the message from. |
TimeSpan | timeout | Timeout after which waiting will be aborted. |
CancellationToken | cancellationToken | Token that can cancel the awaiting. |
Returns
Type | Description |
---|---|
Task<ChatMessage> | Next message. |
Remarks
This method actually uses a CancellationTokenSource under the hood, and simply cancels the token
after specified timeout
.
If the task is cancelled a default (most likely null> value will be returned. TaskCanceledException will not be thrown.
See Also
AwaitNextPrivateByUserAsync(IWolfClient, UInt32, CancellationToken)
Awaits next chat message in PM from specified user.
Declaration
public static Task<ChatMessage> AwaitNextPrivateByUserAsync(this IWolfClient client, uint userID, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | Client to await message from. |
UInt32 | userID | User ID to await the message from. |
CancellationToken | cancellationToken | Token that can cancel the awaiting. |
Returns
Type | Description |
---|---|
Task<ChatMessage> | Next message. |
See Also
AwaitNextPrivateByUserAsync(IWolfClient, UInt32, TimeSpan, CancellationToken)
Awaits next chat message in PM from specified user.
Declaration
public static Task<ChatMessage> AwaitNextPrivateByUserAsync(this IWolfClient client, uint userID, TimeSpan timeout, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | Client to await message from. |
UInt32 | userID | User ID to await the message from. |
TimeSpan | timeout | Timeout after which waiting will be aborted. |
CancellationToken | cancellationToken | Token that can cancel the awaiting. |
Returns
Type | Description |
---|---|
Task<ChatMessage> | Next message. |
Remarks
This method actually uses a CancellationTokenSource under the hood, and simply cancels the token
after specified timeout
.
If the task is cancelled a default (most likely null> value will be returned. TaskCanceledException will not be thrown.