public JinxBotClient(ClientProfile profile) { m_activePlugins = new Dictionary<ProfilePluginConfiguration, IJinxBotPlugin>(); if (profile.SimulateClient) m_client = new SimulatedBattleNetClient(profile); else m_client = new BattleNetClient(profile); m_profile = profile; m_resourceProvider = ProfileResourceProvider.RegisterProvider(m_client); m_cmdTranslator = new CommandTranslator(this); bool hasSetCommandQueue = false; if (m_database == null) m_database = new JinxBotDefaultDatabase(); // finally, initialize ui m_window = new ProfileDocument(this); // initialize plugins m_commandHandlers = new List<ICommandHandler>(); foreach (ProfilePluginConfiguration pluginConfig in profile.PluginSettings) { hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, pluginConfig); } ProfilePluginConfiguration jsConfig = new ProfilePluginConfiguration { Assembly = "JinxBot.Plugins.Script.dll", Name = "JavaScript Plugin", Settings = new ProfilePluginSettingConfiguration[0], Type = "JinxBot.Plugins.Script.JinxBotJavaScriptPlugin" }; hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, jsConfig); if (!hasSetCommandQueue) { m_client.CommandQueue = new TimedMessageQueue(); } }
public void Close() { m_client.Close(); m_cmdTranslator.Dispose(); m_cmdTranslator = null; foreach (ProfilePluginConfiguration config in m_activePlugins.Keys) { IJinxBotPlugin plugin = m_activePlugins[config]; IMultiClientPlugin mcp = plugin as IMultiClientPlugin; if (mcp != null) mcp.RemoveClient(this); ISingleClientPlugin scp = plugin as ISingleClientPlugin; if (scp != null) { scp.UnregisterEvents(this); scp.DestroyPluginWindows(this.ProfileDocument); } PluginFactory.ClosePluginInstance(config, plugin); JinxBotConfiguration.Instance.Save(); } }