mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
use EmptyResult instead of custom NoResponse
This commit is contained in:
parent
513835ed0f
commit
ab188ad54f
2 changed files with 20 additions and 10 deletions
|
@ -217,17 +217,9 @@ namespace BTCPayServer.Controllers
|
|||
leases.Dispose();
|
||||
await CloseSocket(webSocket);
|
||||
}
|
||||
return new NoResponse();
|
||||
return new EmptyResult();
|
||||
}
|
||||
|
||||
class NoResponse : IActionResult
|
||||
{
|
||||
public Task ExecuteResultAsync(ActionContext context)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ArraySegment<Byte> DummyBuffer = new ArraySegment<Byte>(new Byte[1]);
|
||||
private async Task NotifySocket(WebSocket webSocket, string invoiceId, string expectedId)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Logging;
|
||||
using System.Threading;
|
||||
|
||||
namespace BTCPayServer
|
||||
{
|
||||
|
@ -26,8 +27,12 @@ namespace BTCPayServer
|
|||
|
||||
public Action<Object> Act { get; set; }
|
||||
|
||||
bool _Disposed;
|
||||
public void Dispose()
|
||||
{
|
||||
if (_Disposed)
|
||||
return;
|
||||
_Disposed = true;
|
||||
lock (this.aggregator._Subscriptions)
|
||||
{
|
||||
if (this.aggregator._Subscriptions.TryGetValue(t, out Dictionary<Subscription, Action<object>> actions))
|
||||
|
@ -51,6 +56,19 @@ namespace BTCPayServer
|
|||
Dispose();
|
||||
}
|
||||
}
|
||||
public Task<T> WaitNext<T>(CancellationToken cancellation = default(CancellationToken))
|
||||
{
|
||||
return WaitNext<T>(o => true, cancellation);
|
||||
}
|
||||
public async Task<T> WaitNext<T>(Func<T, bool> predicate, CancellationToken cancellation = default(CancellationToken))
|
||||
{
|
||||
TaskCompletionSource<T> tcs = new TaskCompletionSource<T>();
|
||||
var subscription = Subscribe<T>((a, b) => { if (predicate(b)) { tcs.TrySetResult(b); a.Unsubscribe(); } });
|
||||
using (cancellation.Register(() => { tcs.TrySetCanceled(); subscription.Unsubscribe(); }))
|
||||
{
|
||||
return await tcs.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Publish<T>(T evt) where T : class
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue