public void TestImportOverIPC() { using (HeadlessGameHost host = new CleanRunHeadlessGameHost($"{nameof(ImportBeatmapTest)}-host", true)) using (HeadlessGameHost client = new CleanRunHeadlessGameHost($"{nameof(ImportBeatmapTest)}-client", true)) { try { Assert.IsTrue(host.IsPrimaryInstance); Assert.IsFalse(client.IsPrimaryInstance); var osu = LoadOsuIntoHost(host); var temp = TestResources.GetTestBeatmapForImport(); var importer = new ArchiveImportIPCChannel(client); if (!importer.ImportAsync(temp).Wait(10000)) { Assert.Fail(@"IPC took too long to send"); } ensureLoaded(osu); waitForOrAssert(() => !File.Exists(temp), "Temporary still exists after IPC import", 5000); } finally { host.Exit(); } } }
public void TestImportOverIPC() { using (HeadlessGameHost host = new CleanRunHeadlessGameHost("host", true)) using (HeadlessGameHost client = new CleanRunHeadlessGameHost("client", true)) { try { Assert.IsTrue(host.IsPrimaryInstance); Assert.IsFalse(client.IsPrimaryInstance); var osu = loadOsu(host); var temp = prepareTempCopy(osz_path); Assert.IsTrue(File.Exists(temp)); var importer = new ArchiveImportIPCChannel(client); if (!importer.ImportAsync(temp).Wait(10000)) { Assert.Fail(@"IPC took too long to send"); } ensureLoaded(osu); waitForOrAssert(() => !File.Exists(temp), "Temporary still exists after IPC import", 5000); } finally { host.Exit(); } } }
public static void Main(string[] args) { string cwd = CurrentDirectory; using (DesktopGameHost host = Host.GetSuitableHost("Rhythmic", true)) { host.ExceptionThrown += handleException; if (!host.IsPrimaryInstance) { ArchiveImportIPCChannel importer = new ArchiveImportIPCChannel(host); // Restore the cwd so relative paths given at the command line work correctly Directory.SetCurrentDirectory(cwd); foreach (string file in args) { Console.WriteLine(@"Importing {0}", file); if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000)) { throw new TimeoutException(@"IPC took too long to send"); } } } else { switch (args.FirstOrDefault() ?? string.Empty) { default: host.Run(new RhythmicGameDesktop(args)); break; } } } }
public static int Main(string[] args) { // Back up the cwd before DesktopGameHost changes it var cwd = Environment.CurrentDirectory; using (DesktopGameHost host = Host.GetSuitableHost(@"osu", true)) { if (!host.IsPrimaryInstance) { var importer = new ArchiveImportIPCChannel(host); // Restore the cwd so relative paths given at the command line work correctly Directory.SetCurrentDirectory(cwd); foreach (var file in args) { Console.WriteLine(@"Importing {0}", file); if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000)) { throw new TimeoutException(@"IPC took too long to send"); } } } else { switch (args.FirstOrDefault() ?? string.Empty) { default: host.Run(new OsuGameDesktop(args)); break; } } return(0); } }
public static int Main(string[] args) { // Back up the cwd before DesktopGameHost changes it var cwd = Environment.CurrentDirectory; bool useSdl = args.Contains("--sdl"); using (DesktopGameHost host = Host.GetSuitableHost(@"osu", true, useSdl: useSdl)) { host.ExceptionThrown += handleException; if (!host.IsPrimaryInstance) { if (args.Length > 0 && args[0].Contains('.')) // easy way to check for a file import in args { var importer = new ArchiveImportIPCChannel(host); // Restore the cwd so relative paths given at the command line work correctly Directory.SetCurrentDirectory(cwd); foreach (var file in args) { Console.WriteLine(@"Importing {0}", file); if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000)) { throw new TimeoutException(@"IPC took too long to send"); } } return(0); } // we want to allow multiple instances to be started when in debug. if (!DebugUtils.IsDebugBuild) { return(0); } } switch (args.FirstOrDefault() ?? string.Empty) { default: host.Run(new OsuGameDesktop(args)); break; case "--tournament": host.Run(new TournamentGame()); break; } return(0); } }
protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStoreWithFileIncludes <TModel, TFileModel> modelStore, IIpcHost importHost = null) { ContextFactory = contextFactory; ModelStore = modelStore; ModelStore.ItemAdded += item => handleEvent(() => ItemAdded?.Invoke(item)); ModelStore.ItemRemoved += s => handleEvent(() => ItemRemoved?.Invoke(s)); Files = new FileStore(contextFactory, storage); if (importHost != null) { ipc = new ArchiveImportIPCChannel(importHost, this); } ModelStore.Cleanup(); }
protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStoreWithFileIncludes <TModel, TFileModel> modelStore, IIpcHost importHost = null) { ContextFactory = contextFactory; ModelStore = modelStore; ModelStore.ItemUpdated += item => handleEvent(() => itemUpdated.Value = new WeakReference <TModel>(item)); ModelStore.ItemRemoved += item => handleEvent(() => itemRemoved.Value = new WeakReference <TModel>(item)); exportStorage = storage.GetStorageForDirectory("exports"); Files = new FileStore(contextFactory, storage); if (importHost != null) { ipc = new ArchiveImportIPCChannel(importHost, this); } ModelStore.Cleanup(); }
public static void Main(string[] args) { // Back up the cwd before DesktopGameHost changes it string cwd = Environment.CurrentDirectory; string gameName = base_game_name; bool tournamentClient = false; foreach (string arg in args) { string[] split = arg.Split('='); string key = split[0]; string val = split.Length > 1 ? split[1] : string.Empty; switch (key) { case "--tournament": tournamentClient = true; break; case "--debug-client-id": if (!DebugUtils.IsDebugBuild) { throw new InvalidOperationException("Cannot use this argument in a non-debug build."); } if (!int.TryParse(val, out int clientID)) { throw new ArgumentException("Provided client ID must be an integer."); } gameName = $"{base_game_name}-{clientID}"; break; } } using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { BindIPC = true })) { host.ExceptionThrown += handleException; if (!host.IsPrimaryInstance) { if (args.Length > 0 && args[0].Contains('.')) // easy way to check for a file import in args { var importer = new ArchiveImportIPCChannel(host); foreach (string file in args) { Console.WriteLine(@"Importing {0}", file); if (!importer.ImportAsync(Path.GetFullPath(file, cwd)).Wait(3000)) { throw new TimeoutException(@"IPC took too long to send"); } } return; } // we want to allow multiple instances to be started when in debug. if (!DebugUtils.IsDebugBuild) { Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error); return; } } if (host.IsPrimaryInstance) { try { Logger.Log("Starting legacy IPC provider..."); legacyIpc = new LegacyTcpIpcProvider(); legacyIpc.Bind(); } catch (Exception ex) { Logger.Error(ex, "Failed to start legacy IPC provider"); } } if (tournamentClient) { host.Run(new TournamentGame()); } else { host.Run(new OsuGameDesktop(args)); } } }
public static int Main(string[] args) { // Back up the cwd before DesktopGameHost changes it var cwd = Environment.CurrentDirectory; string gameName = base_game_name; bool tournamentClient = false; foreach (var arg in args) { var split = arg.Split('='); var key = split[0]; var val = split.Length > 1 ? split[1] : string.Empty; switch (key) { case "--tournament": tournamentClient = true; break; case "--debug-client-id": if (!DebugUtils.IsDebugBuild) { throw new InvalidOperationException("Cannot use this argument in a non-debug build."); } if (!int.TryParse(val, out int clientID)) { throw new ArgumentException("Provided client ID must be an integer."); } gameName = $"{base_game_name}-{clientID}"; break; } } using (DesktopGameHost host = Host.GetSuitableHost(gameName, true)) { host.ExceptionThrown += handleException; if (!host.IsPrimaryInstance) { if (args.Length > 0 && args[0].Contains('.')) // easy way to check for a file import in args { var importer = new ArchiveImportIPCChannel(host); foreach (var file in args) { Console.WriteLine(@"Importing {0}", file); if (!importer.ImportAsync(Path.GetFullPath(file, cwd)).Wait(3000)) { throw new TimeoutException(@"IPC took too long to send"); } } return(0); } // we want to allow multiple instances to be started when in debug. if (!DebugUtils.IsDebugBuild) { return(0); } } if (tournamentClient) { host.Run(new TournamentGame()); } else { host.Run(new OsuGameDesktop(args)); } return(0); } }