mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Change IPC to make sense.
This commit is contained in:
43
osu.Game/IPC/BeatmapIPCChannel.cs
Normal file
43
osu.Game/IPC/BeatmapIPCChannel.cs
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.IPC
|
||||
{
|
||||
public class BeatmapIPCChannel : IpcChannel<BeatmapImportMessage>
|
||||
{
|
||||
private BeatmapDatabase beatmaps;
|
||||
|
||||
public BeatmapIPCChannel(IIpcHost host, BeatmapDatabase beatmaps = null)
|
||||
: base(host)
|
||||
{
|
||||
this.beatmaps = beatmaps;
|
||||
MessageReceived += (msg) =>
|
||||
{
|
||||
Debug.Assert(beatmaps != null);
|
||||
ImportAsync(msg.Path);
|
||||
};
|
||||
}
|
||||
|
||||
public async Task ImportAsync(string path)
|
||||
{
|
||||
if (beatmaps == null)
|
||||
{
|
||||
//we want to contact a remote osu! to handle the import.
|
||||
await SendMessageAsync(new BeatmapImportMessage { Path = path });
|
||||
return;
|
||||
}
|
||||
|
||||
beatmaps.Import(path);
|
||||
}
|
||||
}
|
||||
|
||||
public class BeatmapImportMessage
|
||||
{
|
||||
public string Path;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user