From 2760e68242dc380fcf00379f889d95391b5a04a8 Mon Sep 17 00:00:00 2001 From: Joe Abbate <40615740+jabbate19@users.noreply.github.com> Date: Sun, 26 Feb 2023 12:37:37 -0500 Subject: [PATCH 1/2] Update DevcadeClient.cs --- onboard/DevcadeClient.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/onboard/DevcadeClient.cs b/onboard/DevcadeClient.cs index 093cea2..4e4e7fd 100644 --- a/onboard/DevcadeClient.cs +++ b/onboard/DevcadeClient.cs @@ -131,6 +131,9 @@ private static void notifyDownloadComplete(DevcadeGame game) { string path = $"/tmp/{gameName}.zip"; try { Console.WriteLine($"Extracting {path}"); + if (Directory.Exists($"/tmp/{gameName}")) { + Directory.Delete($"/tmp/{gameName}", true); + } Directory.CreateDirectory($"/tmp/{gameName}"); ZipFile.ExtractToDirectory(path, $"/tmp/{gameName}"); } catch (Exception e) { From 928b5a72f8878879e1b08bfc198ec4b570893587 Mon Sep 17 00:00:00 2001 From: Joe Abbate <40615740+jabbate19@users.noreply.github.com> Date: Sun, 26 Feb 2023 15:06:46 -0500 Subject: [PATCH 2/2] Add Datadog Reporting for Game --- onboard/DevcadeClient.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/onboard/DevcadeClient.cs b/onboard/DevcadeClient.cs index 4e4e7fd..f4b5e44 100644 --- a/onboard/DevcadeClient.cs +++ b/onboard/DevcadeClient.cs @@ -7,6 +7,8 @@ using System.Xml.Linq; using System.Collections; using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; using Microsoft.Xna.Framework; // FIXME: Is this necessary for the client code? @@ -126,6 +128,27 @@ private void DownloadGame(object gameObj) { notifyDownloadComplete(game); } + public static void reportToDatadog(DevcadeGame game) { + // Create a new UdpClient + UdpClient udpClient = new UdpClient(); + + // Create a new IPEndPoint for the destination IP address and port number + IPAddress ipAddress = IPAddress.Parse("127.0.0.1"); + int port = 8125; + IPEndPoint endPoint = new IPEndPoint(ipAddress, port); + + string gameName = game.name.Replace(' ', '_'); + // Convert the message to a byte array + string message = $"devcade.game_launch.{gameName}:1|c"; + byte[] bytes = System.Text.Encoding.UTF8.GetBytes(message); + + // Send the message + udpClient.Send(bytes, bytes.Length, endPoint); + + // Close the UdpClient + udpClient.Close(); + } + private static void notifyDownloadComplete(DevcadeGame game) { string gameName = game.name.Replace(' ', '_'); string path = $"/tmp/{gameName}.zip"; @@ -143,6 +166,7 @@ private static void notifyDownloadComplete(DevcadeGame game) { try { string execPath = $"/tmp/{gameName}/publish/{gameName.Replace("_", " ")}"; Console.WriteLine($"Running {execPath}"); + reportToDatadog(game); Chmod(execPath, "+x"); Process proc = new() { StartInfo = new ProcessStartInfo(execPath) {