diff --git a/.vs/StreamLabs_Helper/DesignTimeBuild/.dtbcache.v2 b/.vs/StreamLabs_Helper/DesignTimeBuild/.dtbcache.v2 index 3dea57f..b8c5ab5 100644 Binary files a/.vs/StreamLabs_Helper/DesignTimeBuild/.dtbcache.v2 and b/.vs/StreamLabs_Helper/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 028eaf5..6b61141 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -2,6 +2,5 @@ "ExpandedNodes": [ "" ], - "SelectedNode": "\\WebParser.cs", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 60d08a6..30f7405 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/DataManager.cs b/DataManager.cs index 33a6b22..be6b848 100644 --- a/DataManager.cs +++ b/DataManager.cs @@ -5,7 +5,7 @@ namespace StreamLabs_Helper { public class DataManager { - private static string defaultUrl = "https://w2g.tv/rooms/e6shdqxijs69ovevtd?lang=en"; + private static string defaultUrl = "https://w2g.tv/rooms/challengerandymusic-h749vkhemnt5dmld09?lang=en"; private static string prefFileName = "Preferences.txt"; private static string preferenceFilePath; diff --git a/ProgramManager.cs b/ProgramManager.cs index 91b9f9e..c9efb23 100644 --- a/ProgramManager.cs +++ b/ProgramManager.cs @@ -1,6 +1,5 @@ using System; using System.Timers; -using System.Threading; using System.Threading.Tasks; namespace StreamLabs_Helper @@ -90,7 +89,7 @@ static void Timer_Elapsed(object sender, ElapsedEventArgs e) Set_Timer(timerInterval); } - static async Task FindIFrameDontUpdateDelegate() //might need to de-async this since it needs to run once before program can do anything + static async Task FindIFrameDontUpdateDelegate() { var result = await parser.FindIFrameOnPage(url); Console.WriteLine("iframeResult: " + result); @@ -114,10 +113,10 @@ static void Timer_Elapsed(object sender, ElapsedEventArgs e) try { string foundText = await parser.GetIFrameTitle(); - Console.WriteLine("foundText: " + foundText); if (foundText is null) { return WebParser.ParsingStatus.Failure; } + Console.WriteLine("foundText: " + foundText); server.UpdateResponse(foundText); return WebParser.ParsingStatus.Success; } @@ -128,6 +127,11 @@ static void Timer_Elapsed(object sender, ElapsedEventArgs e) } } + public static void Print(string message) + { + Console.WriteLine((message ?? "empty message") + Environment.NewLine); + } + public static void Error(string message = "unspecified error", bool fatal = false) { Console.WriteLine(message + "\n"); diff --git a/Server.cs b/Server.cs index e3832a6..1494694 100644 --- a/Server.cs +++ b/Server.cs @@ -11,23 +11,13 @@ class Server : IDisposable { static volatile HttpListener _httpListener = new HttpListener(); Thread _responseThread; - private string responsePrefix; - private string responseSuffix; private string responseString; private object threadLock = new object(); private bool shouldRun = true; public Server(string message = null) { - string parseInterval = (ProgramManager.timerInterval / 1000).ToString(); - Console.WriteLine("parseInterval: " + parseInterval); - responsePrefix = - "Watch2Gether Title Displayer"; - responseSuffix = ""; - string defaultWelcome = responsePrefix + "Server initializing.... If this takes longer than 10 seconds," + - "then it's bugged. Check to make sure a youtube video is playing (not a built-in Blender short), then restart this app." + responseSuffix; - responseString = message ?? defaultWelcome; + responseString = WebSite.FormSite(message); } public bool StartServer(string mode) @@ -100,9 +90,9 @@ void ResponseThread() } } - public void UpdateResponse(string response) //updates the reponse that the server will display + public void UpdateResponse(string newResponse) //updates the reponse that the server will display { - responseString = responsePrefix + response + responseSuffix; + responseString = WebSite.FormSite(newResponse); } public static bool IsAdministrator() diff --git a/WebSite.cs b/WebSite.cs new file mode 100644 index 0000000..0e2250d --- /dev/null +++ b/WebSite.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StreamLabs_Helper +{ + static class WebSite + { + static private int updateInterval = 3; //change to use WebSite as timer authority + public static string defaultMessage { get; } = "Server initializing.... If this takes longer than 10 seconds," + + "then it's bugged. Check to make sure a youtube video is playing (not a built-in Blender short), then restart this app."; + private static HtmlStruct SiteHtml; + private static string cssText = @""; + + struct HtmlStruct + { + public string head; + public string bodyPrefix; + public string bodySuffix; + } + + static WebSite() + { + ProgramManager.Print("updateInterval: " + updateInterval); + FormHtml(); + } + + public static string FormSite(string message) + { + if (message is not null) + return (SiteHtml.head + SiteHtml.bodyPrefix + message + SiteHtml.bodySuffix); + else + return defaultMessage; + } + + private static void FormHtml() + { + SiteHtml.head = FormHead(updateInterval, cssText); + SiteHtml.bodyPrefix = ""; + SiteHtml.bodySuffix = ""; + } + + private static string FormHead(int refreshRate, string css) + { + return "Watch2Gether Title Displayer" + css + ""; + } + } +} diff --git a/XmlHelper.cs b/XmlHelper.cs index f443ff7..7f3e8f6 100644 --- a/XmlHelper.cs +++ b/XmlHelper.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Text; -using System.Threading.Tasks; using System.Xml; using System.Xml.Serialization; using System.IO;