diff --git a/Dotnet/AppApi/Common/AppApiCommon.cs b/Dotnet/AppApi/Common/AppApiCommon.cs index 14d9c4ab..32adf2ff 100644 --- a/Dotnet/AppApi/Common/AppApiCommon.cs +++ b/Dotnet/AppApi/Common/AppApiCommon.cs @@ -5,6 +5,7 @@ using System.Globalization; using System.IO; using System.Security.Cryptography; using System.Text; +using System.Threading.Tasks; using librsync.net; using Newtonsoft.Json; using NLog; @@ -165,5 +166,10 @@ namespace VRCX return null; } + + public Task TryOpenInstanceInVrc(string launchUrl) + { + return VRCIPC.Send(launchUrl); + } } } \ No newline at end of file diff --git a/Dotnet/IPC/VRCIPC.cs b/Dotnet/IPC/VRCIPC.cs new file mode 100644 index 00000000..37c33d1a --- /dev/null +++ b/Dotnet/IPC/VRCIPC.cs @@ -0,0 +1,43 @@ +using System.IO.Pipes; +using System.Text; +using System.Threading.Tasks; + +namespace VRCX; + +public class VRCIPC +{ + private const string PipeName = "VRChatURLLaunchPipe"; + private static NamedPipeClientStream _ipcClient; + + private static void TryConnect() + { + if (_ipcClient != null && _ipcClient.IsConnected) + return; + + _ipcClient = new NamedPipeClientStream(".", PipeName, PipeDirection.InOut); + _ipcClient.Connect(1000); + } + + public static async Task Send(string message) + { + TryConnect(); + if (_ipcClient == null || !_ipcClient.IsConnected) + { + Dispose(); + return false; + } + + var bytes = Encoding.UTF8.GetBytes(message); + _ipcClient.Write(bytes, 0, bytes.Length); + var result = new byte[1]; + await _ipcClient.ReadExactlyAsync(result, 0, 1); + Dispose(); + return result[0] == 1; + } + + private static void Dispose() + { + _ipcClient?.Close(); + _ipcClient = null; + } +} \ No newline at end of file diff --git a/src/components/InviteYourself.vue b/src/components/InviteYourself.vue index 79a80a11..da9723fd 100644 --- a/src/components/InviteYourself.vue +++ b/src/components/InviteYourself.vue @@ -1,24 +1,51 @@ diff --git a/src/components/dialogs/GroupDialog/GroupDialog.vue b/src/components/dialogs/GroupDialog/GroupDialog.vue index 15ef8aa6..82a9da06 100644 --- a/src/components/dialogs/GroupDialog/GroupDialog.vue +++ b/src/components/dialogs/GroupDialog/GroupDialog.vue @@ -413,9 +413,7 @@
- - - + {{ t('dialog.launch.invite') }} - - {{ t('dialog.launch.launch') }} - + + @@ -88,6 +106,7 @@ import { useAppearanceSettingsStore, useFriendStore, + useGameStore, useInstanceStore, useLaunchStore, useLocationStore @@ -100,9 +119,10 @@ const { friends } = storeToRefs(useFriendStore()); const { hideTooltips } = storeToRefs(useAppearanceSettingsStore()); const { lastLocation } = storeToRefs(useLocationStore()); - const { launchGame } = useLaunchStore(); + const { launchGame, tryOpenInstanceInVrc } = useLaunchStore(); const { launchDialogData } = storeToRefs(useLaunchStore()); const { showPreviousInstancesInfoDialog } = useInstanceStore(); + const { isGameRunning } = storeToRefs(useGameStore()); const launchDialogRef = ref(null); @@ -180,6 +200,10 @@ launchGame(location, shortName, desktop); isVisible.value = false; } + function handleAttachGame(location, shortName) { + tryOpenInstanceInVrc(location, shortName); + isVisible.value = false; + } function getConfig() { configRepository.getBool('launchAsDesktop').then((value) => (launchDialog.value.desktop = value)); } diff --git a/src/components/dialogs/UserDialog/UserDialog.vue b/src/components/dialogs/UserDialog/UserDialog.vue index e3337c75..ada3a095 100644 --- a/src/components/dialogs/UserDialog/UserDialog.vue +++ b/src/components/dialogs/UserDialog/UserDialog.vue @@ -568,15 +568,10 @@