discord-rpc-csharp icon indicating copy to clipboard operation
discord-rpc-csharp copied to clipboard

WARN: Empty frame was read. Please send report to Lachee.

Open TheRealAyCe opened this issue 5 years ago • 0 comments

Your API told me to send a report.

I started more or less the demo code in a WPF app.


#nullable enable

using DiscordRPC;
using DiscordRPC.Logging;
using System;
using System.Threading.Tasks;

namespace DiscordCommunication
{
	public class DiscordService : IDisposable
	{
		private readonly DiscordRpcClient _client;

		public DiscordService()
		{
			_client = new DiscordRpcClient(
				"...",
				-1,
				new ConsoleLogger() { Level = LogLevel.Warning },
				false
			);

			//Subscribe to events
			_client.OnReady += (sender, e) =>
			{
				Console.WriteLine("Received Ready from user {0}", e.User.Username);
			};

			_client.OnPresenceUpdate += (sender, e) =>
			{
				Console.WriteLine("Received Update! {0}", e.Presence);
			};

			//Connect to the RPC
			_client.Initialize();

			//Set the rich presence
			//Call this as many times as you want and anywhere in your code.
			_client.SetPresence(new RichPresence()
			{
				Details = "Example Project",
				State = "csharp example",
				Assets = new Assets()
				{
					LargeImageKey = "x",
					LargeImageText = "x",
					SmallImageKey = "x"
				}
			});

			Loop();
		}

		private async void Loop()
		{
			try
			{
				while (!_client.IsDisposed)
				{
					_client.Invoke();
					await Task.Delay(1000);
				}
			}
			catch (Exception e)
			{
				Console.WriteLine($"OUCH: {e}");
			}
		}

		public void Dispose()
		{
			_client.Dispose();
		}
	}
}

Then I left the app running and exited Discord.

TheRealAyCe avatar Jun 18 '20 21:06 TheRealAyCe