3xpl websocket client in case anyone wanted one. Don't bother using it though, their websocket service is a piece of shit that's totally broken which I only found out after wasting a day on it.

This commit is contained in:
barelyprofessional
2024-06-16 12:18:56 +08:00
parent cdad1d6549
commit 5cdab275c3
12 changed files with 4026 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
using System.Text.Json;
using Spectre.Console;
using ThreeXplWsClient.Events;
namespace ThreeXplCliClient;
public class ThreeXplClient
{
private List<string> _addresses =
[
"MC8TiBEsnQVjxbvLtTsUXjTBZTQaR8fe8X",
"ltc1qks2m7hvmhs3c20zrfvptv9pvk82p8g70sgw5mk"
];
public async Task Start()
{
var client = new ThreeXplWsClient.ThreeXplWsClient();
client.OnThreeXplPush += OnThreeXplEvent;
await client.StartWsClient();
while (true)
{
var prompt = AnsiConsole.Ask<string>("Channel: ");
client.SendSubscribeRequest(prompt);
}
}
private void OnThreeXplEvent(object sender, ThreeXplPushModel e, int connectionId)
{
AnsiConsole.MarkupLine("[blue]Received event from 3xpl[/]");
foreach (var txn in e.Pub.Data.Data)
{
if (txn.Address == null) return;
if (_addresses.Contains(txn.Address))
{
AnsiConsole.MarkupLine($"[green]Saw txn I'm interested in: {txn.Address}, effect {txn.Effect}, currency {txn.Currency}[/]");
}
}
}
}