public void Initialize(ISharpControl control) { _controlPanel = new SettingsPanel(); _control = control; if (Utils.GetBooleanSetting("EnableRPC", true)) { if (Utils.GetStringSetting("ClientID").Replace(" ", "").Length != 18) { Utils.SaveSetting("ClientID", "765213507321856078"); } client = new DiscordRpcClient(Utils.GetStringSetting("ClientID"), pipe: discordPipe) { Logger = new ConsoleLogger(logLevel, true) }; client.RegisterUriScheme(); client.OnRpcMessage += Client_OnRpcMessage; client.OnPresenceUpdate += Client_OnPresenceUpdate; client.OnReady += OnReady; client.OnClose += OnClose; client.OnError += OnError; client.OnConnectionEstablished += OnConnectionEstablished; client.OnConnectionFailed += OnConnectionFailed; presence.Timestamps = new Timestamps { Start = DateTime.UtcNow }; client.SkipIdenticalPresence = true; client.SetPresence(presence); client.Initialize(); _ = MainLoop(); } else { _controlPanel.ChangeStatus = "RPC is disabled"; } LogWriter.WriteToFile("EOM Initialize"); }
public void Initialize(ISharpControl control) { IConfigurationPanelProvider configurationPanelProvider; if (Utils.GetBooleanSetting("ShowWelcomePage", true)) { new WelcomeForm().ShowDialog(); } _controlPanel = new SettingsPanel(); windowMessages = new TopWindowMessages(); // TODO: do something when "EnableRPCInvite" is set to false _control = control; try { if (Utils.GetBooleanSetting("EnableRPCInvite", false)) { _control.RegisterFrontControl(windowMessages, PluginPosition.Top); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } if (Utils.GetBooleanSetting("EnableRPCInvite", false)) { presence.Secrets = new Secrets() { JoinSecret = "invalid_secret" }; presence.Party = new Party() { ID = Secrets.CreateFriendlySecret(new Random()), Size = 1, Max = 100 }; } if (Utils.GetBooleanSetting("EnableRPCInvite", false)) { windowMessages.Show(); } if (Utils.GetBooleanSetting("EnableRPC", true)) { if (RPCalreadyLoaded) { _controlPanel.ChangeStatus = "Restart required"; return; } if (Utils.GetStringSetting("ClientID").Replace(" ", "").Length != 18) { client = new DiscordRpcClient("765213507321856078", pipe: discordPipe) { Logger = new ConsoleLogger(logLevel, true) }; } else { client = new DiscordRpcClient(Utils.GetStringSetting("ClientID"), pipe: discordPipe) { Logger = new ConsoleLogger(logLevel, true) }; } client.RegisterUriScheme(); client.OnRpcMessage += Client_OnRpcMessage; client.OnPresenceUpdate += Client_OnPresenceUpdate; client.OnReady += OnReady; client.OnClose += OnClose; client.OnError += OnError; client.OnConnectionEstablished += OnConnectionEstablished; client.OnConnectionFailed += OnConnectionFailed; client.OnSubscribe += OnSubscribe; client.OnUnsubscribe += OnUnsubscribe; client.OnJoin += OnJoin; client.OnJoinRequested += OnJoinRequested; presence.Timestamps = new Timestamps() { Start = DateTime.UtcNow }; if (Utils.GetBooleanSetting("EnableRPCInvite", false)) { client.SetSubscription(EventType.Join | EventType.JoinRequest); } client.SetPresence(presence); client.Initialize(); try { configurationPanelProvider = (IConfigurationPanelProvider)_control.Source; controllerPanel = (SDRSharp.FrontEnds.SpyServer.ControllerPanel)configurationPanelProvider.Gui; } catch (Exception ex) { LogWriter.WriteToFile("----> " + ex); MessageBox.Show($"Cannot get Spy Server Network address\n\nError:\n{ex}", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } _ = MainLoop(); } else { _controlPanel.ChangeStatus = "RPC is disabled"; } LogWriter.WriteToFile("EOM Initialize"); }