diff --git a/ChannelPointsSFX/alert.html b/ChannelPointsSFX/alert.html new file mode 100644 index 0000000..0f0efad --- /dev/null +++ b/ChannelPointsSFX/alert.html @@ -0,0 +1,86 @@ + + + + + + + + + +
+
|DISPLAY_NAME|
 odebraƂ  
|TITLE|
 ( |COST|) +
+ + \ No newline at end of file diff --git a/ChannelPointsSFX/frmMain.cs b/ChannelPointsSFX/frmMain.cs index 6f46e73..5bb9c14 100644 --- a/ChannelPointsSFX/frmMain.cs +++ b/ChannelPointsSFX/frmMain.cs @@ -63,6 +63,7 @@ private void HandleConnections(object state) private static async Task HandleIncomingConnections() { + string alertSchema = File.ReadAllText("alert.html"); while (!killServer) { HttpListenerContext ctx = await listener.GetContextAsync(); @@ -71,23 +72,35 @@ private static async Task HandleIncomingConnections() string headStr = "", bodyStr = ""; if (req.Url.AbsolutePath == "/") { - headStr = ""; if (File.Exists("alert.txt")) { - bodyStr = File.ReadAllText("alert.txt"); + String[] alertData = File.ReadAllLines("alert.txt"); + if (alertData.Length == 3) + { + bodyStr = alertSchema.Replace("|DISPLAY_NAME|", alertData[0]).Replace("|TITLE|", alertData[1]).Replace("|COST|", alertData[2]); + } + } + else + { + headStr = ""; } } - byte[] data = Encoding.UTF8.GetBytes("" + - "" + - "" + - "" + - headStr + - "" + - "" + - bodyStr + - "" + - ""); + byte[] data = Encoding.UTF8.GetBytes(""); + if (headStr.Length > 0) + { + data = Encoding.UTF8.GetBytes("" + + "" + + "" + + "" + + headStr + + "" + + ""); + } + else if (bodyStr.Length > 0) + { + data = Encoding.UTF8.GetBytes(bodyStr); + } HttpListenerResponse resp = ctx.Response; resp.ContentType = "text/html"; @@ -240,7 +253,7 @@ private void BuildAlert(string Title, string DisplayName, int RewardCost, string } else { - File.WriteAllText("alert.txt", "

" + Title + "

\n

" + DisplayName + "

\n

" + RewardCost + "

"); + File.WriteAllText("alert.txt", DisplayName + "\n" + Title + "\n" + RewardCost); Task.Delay(500).ContinueWith((task) => { PlaySound(Sound); });