forked from blish-hud/Blish-HUD
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
76 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Blish HUD/GameServices/ArcDps/V2/IArcDpsMessageListener.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Blish_HUD.GameServices.ArcDps.V2 { | ||
public interface IArcDpsMessageListener<T> : IDisposable | ||
where T : struct { | ||
event Action<IArcDpsMessageListener<T>> Disposing; | ||
|
||
MessageType MessageType { get; } | ||
|
||
Task HandleAsync(T message, CancellationToken ct); | ||
} | ||
|
||
public class ArcDpsMessageListener<T> : IArcDpsMessageListener<T> | ||
where T : struct { | ||
private readonly Func<T, CancellationToken, Task> listener; | ||
|
||
public MessageType MessageType { get; } | ||
|
||
public event Action<IArcDpsMessageListener<T>> Disposing; | ||
|
||
public ArcDpsMessageListener(MessageType type, Func<T, CancellationToken, Task> listener) { | ||
this.MessageType = type; | ||
this.listener = listener; | ||
} | ||
|
||
public async Task HandleAsync(T message, CancellationToken ct) | ||
=> await this.listener(message, ct); | ||
|
||
public void Dispose() { | ||
this.Disposing?.Invoke(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters