mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:23:22 +08:00
Merge pull request #27908 from smoogipoo/silence-flatpak-exception
Globally silence Discord RPC registration failures
This commit is contained in:
commit
6f84467190
@ -6,7 +6,6 @@ using System.Text;
|
|||||||
using DiscordRPC;
|
using DiscordRPC;
|
||||||
using DiscordRPC.Message;
|
using DiscordRPC.Message;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
@ -80,14 +79,20 @@ namespace osu.Desktop
|
|||||||
client.OnReady += onReady;
|
client.OnReady += onReady;
|
||||||
client.OnError += (_, e) => Logger.Log($"An error occurred with Discord RPC Client: {e.Message} ({e.Code})", LoggingTarget.Network, LogLevel.Error);
|
client.OnError += (_, e) => Logger.Log($"An error occurred with Discord RPC Client: {e.Message} ({e.Code})", LoggingTarget.Network, LogLevel.Error);
|
||||||
|
|
||||||
// A URI scheme is required to support game invitations, as well as informing Discord of the game executable path to support launching the game when a user clicks on join/spectate.
|
try
|
||||||
// The library doesn't properly support URI registration when ran from an app bundle on macOS.
|
|
||||||
if (!RuntimeInfo.IsApple)
|
|
||||||
{
|
{
|
||||||
client.RegisterUriScheme();
|
client.RegisterUriScheme();
|
||||||
client.Subscribe(EventType.Join);
|
client.Subscribe(EventType.Join);
|
||||||
client.OnJoin += onJoin;
|
client.OnJoin += onJoin;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// This is known to fail in at least the following sandboxed environments:
|
||||||
|
// - macOS (when packaged as an app bundle)
|
||||||
|
// - flatpak (see: https://github.com/flathub/sh.ppy.osu/issues/170)
|
||||||
|
// There is currently no better way to do this offered by Discord, so the best we can do is simply ignore it for now.
|
||||||
|
Logger.Log($"Failed to register Discord URI scheme: {ex}");
|
||||||
|
}
|
||||||
|
|
||||||
client.Initialize();
|
client.Initialize();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user