mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
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:
15
ThreeXplCliClient/NLog.config
Normal file
15
ThreeXplCliClient/NLog.config
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
|
||||
autoReload="true"
|
||||
throwExceptions="false"
|
||||
internalLogLevel="Off" internalLogFile="~/nlog-internal.log">
|
||||
<targets>
|
||||
<target xsi:type="Console" name="console"/>
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="console" />
|
||||
</rules>
|
||||
</nlog>
|
||||
3483
ThreeXplCliClient/NLog.xsd
Normal file
3483
ThreeXplCliClient/NLog.xsd
Normal file
File diff suppressed because it is too large
Load Diff
18
ThreeXplCliClient/Program.cs
Normal file
18
ThreeXplCliClient/Program.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Spectre.Console;
|
||||
using ThreeXplWsClient.Events;
|
||||
|
||||
namespace ThreeXplCliClient
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
AnsiConsole.MarkupLine("[green]3xpl test client started[/]");
|
||||
var cliClient = new ThreeXplClient();
|
||||
await cliClient.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
30
ThreeXplCliClient/ThreeXplCliClient.csproj
Normal file
30
ThreeXplCliClient/ThreeXplCliClient.csproj
Normal file
@@ -0,0 +1,30 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NLog" Version="5.3.2" />
|
||||
<PackageReference Include="Spectre.Console" Version="0.49.1" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ThreeXplWsClient\ThreeXplWsClient.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Remove="NLog.config" />
|
||||
<Content Include="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
38
ThreeXplCliClient/ThreeXplClient.cs
Normal file
38
ThreeXplCliClient/ThreeXplClient.cs
Normal 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}[/]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user