]> git.deb.at Git - rhonda/impostor.git/commitdiff
Implement scheme handler, passing imposter://hostname as an argument to the Client...
authorMichael Biggins <mike@cubecoders.com>
Mon, 28 Sep 2020 19:05:15 +0000 (20:05 +0100)
committerMichael Biggins <mike@cubecoders.com>
Mon, 28 Sep 2020 19:05:15 +0000 (20:05 +0100)
src/Impostor.Client/Program.cs

index 647044b13b534d8d5228d4b7e154a77c319e6856..2cacc4a5884952ccccc2f2479be4b14e981d740c 100644 (file)
@@ -1,5 +1,9 @@
 using System;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading.Tasks;
 using System.Windows.Forms;
+using Impostor.Client.Core;
 using Impostor.Client.Forms;
 
 namespace Impostor.Client
@@ -9,9 +13,24 @@ namespace Impostor.Client
         [STAThread]
         private static void Main()
         {
+            var firstArg = Environment.GetCommandLineArgs().FirstOrDefault();
+
+            if (firstArg != null && Uri.TryCreate(firstArg, UriKind.Absolute, out var uri) && uri.Scheme.ToLower() == "imposter")
+            {
+                HandleUri(uri).GetAwaiter().GetResult();
+                return;
+            }
+
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             Application.Run(new FrmMain());
         }
+
+        private static async Task HandleUri(Uri uri)
+        {
+            var modifier = new AmongUsModifier();
+            await modifier.SaveIp(uri.Host);
+            Process.Start("steam://launch/945360");
+        }
     }
 }
\ No newline at end of file