From 81ebb9f47568c70d46a54d2dffb04370ffde04e4 Mon Sep 17 00:00:00 2001 From: Tim Miller Date: Sat, 19 Oct 2024 09:32:57 +0900 Subject: [PATCH] Jetstream sample --- samples/Jetstream/Jetstream.csproj | 18 +++++++++++++++++ samples/Jetstream/Jetstream.sln | 28 +++++++++++++++++++++++++++ samples/Jetstream/Program.cs | 31 ++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 samples/Jetstream/Jetstream.csproj create mode 100644 samples/Jetstream/Jetstream.sln create mode 100644 samples/Jetstream/Program.cs diff --git a/samples/Jetstream/Jetstream.csproj b/samples/Jetstream/Jetstream.csproj new file mode 100644 index 00000000..f138398d --- /dev/null +++ b/samples/Jetstream/Jetstream.csproj @@ -0,0 +1,18 @@ + + + + + + + + Exe + net8.0 + enable + enable + true + + + + + + diff --git a/samples/Jetstream/Jetstream.sln b/samples/Jetstream/Jetstream.sln new file mode 100644 index 00000000..a3cce401 --- /dev/null +++ b/samples/Jetstream/Jetstream.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FishyFlip", "..\..\src\FishyFlip\FishyFlip.csproj", "{48260865-FB6C-4F37-B80B-4CF1F8B52E66}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jetstream", "Jetstream.csproj", "{D80F3939-6001-4EFE-B574-26771F9B7523}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {48260865-FB6C-4F37-B80B-4CF1F8B52E66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {48260865-FB6C-4F37-B80B-4CF1F8B52E66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {48260865-FB6C-4F37-B80B-4CF1F8B52E66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {48260865-FB6C-4F37-B80B-4CF1F8B52E66}.Release|Any CPU.Build.0 = Release|Any CPU + {D80F3939-6001-4EFE-B574-26771F9B7523}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D80F3939-6001-4EFE-B574-26771F9B7523}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D80F3939-6001-4EFE-B574-26771F9B7523}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D80F3939-6001-4EFE-B574-26771F9B7523}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/samples/Jetstream/Program.cs b/samples/Jetstream/Program.cs new file mode 100644 index 00000000..78c0bf40 --- /dev/null +++ b/samples/Jetstream/Program.cs @@ -0,0 +1,31 @@ +// +// Copyright (c) Drastic Actions. All rights reserved. +// + +using FishyFlip; +using Microsoft.Extensions.Logging.Debug; + +Console.WriteLine("Hello, Jetstream!"); + +var debugLog = new DebugLoggerProvider(); + +// You can set a custom url with WithInstanceUrl +var jetstreamBuilder = new ATJetStreamBuilder() + .WithLogger(debugLog.CreateLogger("FishyFlipDebug")); +var atWebProtocol = jetstreamBuilder.Build(); + +atWebProtocol.OnConnectionUpdated += (sender, args) => +{ + Console.WriteLine($"Connection Updated: {args.State}"); +}; + +atWebProtocol.OnRecordReceived += (sender, args) => +{ + Console.WriteLine($"Record Received: {args.Record.Type}"); +}; + +await atWebProtocol.ConnectAsync(); + +var key = Console.ReadKey(); + +await atWebProtocol.CloseAsync(); \ No newline at end of file