From 09c69bcd196594298e896cf334047ca8dfc3e15e Mon Sep 17 00:00:00 2001 From: "Adam R. Grey" Date: Sun, 24 Oct 2021 01:25:17 -0400 Subject: [PATCH] even more cleanup --- .vscode/launch.json | 2 +- .vscode/tasks.json | 6 +++--- Program.cs | 18 +++++++++--------- TwitchEventSub/Receiver.cs | 7 ++++--- twitcher.csproj => twitch-agent.csproj | 0 5 files changed, 17 insertions(+), 16 deletions(-) rename twitcher.csproj => twitch-agent.csproj (100%) diff --git a/.vscode/launch.json b/.vscode/launch.json index 3ba46bb..b45ba5b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/bin/Debug/net5.0/twitcher.dll", + "program": "${workspaceFolder}/bin/Debug/net5.0/twitch-agent.dll", "args": [], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 083d814..6c3bb9d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,7 +7,7 @@ "type": "process", "args": [ "build", - "${workspaceFolder}/twitcher.csproj", + "${workspaceFolder}/twitch-agent.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], @@ -19,7 +19,7 @@ "type": "process", "args": [ "publish", - "${workspaceFolder}/twitcher.csproj", + "${workspaceFolder}/twitch-agent.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], @@ -32,7 +32,7 @@ "args": [ "watch", "run", - "${workspaceFolder}/twitcher.csproj", + "${workspaceFolder}/twitch-agent.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], diff --git a/Program.cs b/Program.cs index 15b4ecf..f93b7d0 100644 --- a/Program.cs +++ b/Program.cs @@ -1,5 +1,6 @@ using franz; using System; +using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using TwitchEventSub.Types.EventSubSubscription; @@ -36,16 +37,15 @@ namespace twitcher //tf.ProduceMessage(new silver_messages.directorial.execute_command(){command = "ssl_expose", args = {twitcherConf.port.ToString()}}); httpd = new TwitchEventSub.Receiver(twitcherConf.port, twitcherConf.clientId, twitcherConf.clientSecret, twitcherConf.public_uri); - Task.WaitAll( - httpd.go(), - Task.Run(() => {httpd.Subscribe(SubscribableTypes.channel_follow, - new TwitchEventSub.Types.Conditions.ChannelFollow() { broadcaster_user_id = "12826" }, - (tg) => { - Console.WriteLine("I'm the handler for a twitchogram!"); - Console.WriteLine(JsonConvert.SerializeObject(tg)); - } - );}) + var theRunTask = httpd.go(); + httpd.Subscribe(SubscribableTypes.channel_follow, + new TwitchEventSub.Types.Conditions.ChannelFollow() { broadcaster_user_id = "12826" }, + (tg) => { + Console.WriteLine("I'm the handler for a twitchogram!"); + Console.WriteLine(JsonConvert.SerializeObject(tg)); + } ); + Task.WaitAll(theRunTask); } } } diff --git a/TwitchEventSub/Receiver.cs b/TwitchEventSub/Receiver.cs index 24c957f..1127755 100644 --- a/TwitchEventSub/Receiver.cs +++ b/TwitchEventSub/Receiver.cs @@ -133,7 +133,6 @@ namespace TwitchEventSub HttpListenerResponse response = context.Response; string page = context.Request.Url.LocalPath.Substring(1); - Console.WriteLine($"{DateTime.Now.ToShortTimeString()} page requested: {page}"); var resp = "no resource"; response.StatusCode = (int)HttpStatusCode.NotFound; lock (psuedoResources) @@ -213,8 +212,10 @@ namespace TwitchEventSub } } } - - Console.WriteLine($"returning status code {response.StatusCode}"); + if(response.StatusCode != (int)HttpStatusCode.OK) + { + Console.WriteLine($"returning status code {response.StatusCode}"); + } byte[] buffer = Encoding.UTF8.GetBytes(resp); response.ContentLength64 = buffer.Length; Stream st = response.OutputStream; diff --git a/twitcher.csproj b/twitch-agent.csproj similarity index 100% rename from twitcher.csproj rename to twitch-agent.csproj