QR and payment fixes

This commit is contained in:
Savya Bikram Shah
2026-05-07 16:43:28 +05:45
parent 906ebbcac9
commit 846a4fda9c
20 changed files with 135 additions and 433 deletions

View File

@@ -13,6 +13,7 @@ namespace Darkmatter.Fonepay
internal event Action<bool> OnQrVerified;
internal event Action<WebsocketMessage<QRPaymentStatus>> OnPaymentReceived;
internal event Action<string> OnRawMessage;
internal event Action<Exception> OnClosed;
private ClientWebSocket _client;
private CancellationTokenSource _cts;
@@ -51,6 +52,7 @@ namespace Darkmatter.Fonepay
CancellationToken cancellationToken)
{
var buffer = new byte[4096];
Exception error = null;
try
{
@@ -70,9 +72,9 @@ namespace Darkmatter.Fonepay
{
// Expected during disconnect.
}
catch (WebSocketException)
catch (WebSocketException ex)
{
// Network disconnect or broken socket.
error = ex;
}
catch (ObjectDisposedException)
{
@@ -80,7 +82,11 @@ namespace Darkmatter.Fonepay
}
catch (Exception ex)
{
Console.WriteLine($"WebSocket receive error: {ex.Message}");
error = ex;
}
finally
{
OnClosed?.Invoke(error);
}
}