/// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> public void Dispose() { if (disposed) { return; } disposed = true; if (WorkerQueryRunner != null) { WorkerQueryRunner.AddLogEntry(new LogEntryLight(LogLevel.Info, string.Format("TS3-Bot '{0}' disconnected.", BotInstance.Settings.Global.BotNickname))); } if (TcpDispatcher != null && TcpDispatcher.IsConnected && !TcpDispatcher.IsDisposed && QueryRunner != null) { QueryRunner.Logout(); QueryRunner.Quit(); TcpDispatcher.Disconnect(); } if (WorkerTcpDispatcher != null && WorkerTcpDispatcher.IsConnected && !WorkerTcpDispatcher.IsDisposed && WorkerQueryRunner != null) { WorkerQueryRunner.Logout(); WorkerQueryRunner.Quit(); WorkerTcpDispatcher.Disconnect(); } if (NotificationTcpDispatcher != null && NotificationTcpDispatcher.IsConnected && !NotificationTcpDispatcher.IsDisposed && NotificationQueryRunner != null) { NotificationQueryRunner.Logout(); NotificationQueryRunner.Quit(); NotificationTcpDispatcher.Disconnect(); } GC.SuppressFinalize(this); }
/// <summary> /// Inits the notification. /// </summary> private void InitNotification() { NotificationQueryRunner.Login(BotInstance.Settings.TeamSpeak.Username, BotInstance.Settings.TeamSpeak.Password); if (BotInstance.Settings.TeamSpeak.InstancePort > 0) { NotificationQueryRunner.SelectVirtualServerByPort(BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault()); } else { NotificationQueryRunner.SelectVirtualServerById(BotInstance.Settings.TeamSpeak.Instance.GetValueOrDefault()); } NotificationQueryRunner.RegisterForNotifications(ServerNotifyRegisterEvent.Server); NotificationQueryRunner.RegisterForNotifications(ServerNotifyRegisterEvent.Channel, BotInstance.Settings.Sticky.Channel); NotificationQueryRunner.RegisterForNotifications(ServerNotifyRegisterEvent.TextChannel); NotificationQueryRunner.RegisterForNotifications(ServerNotifyRegisterEvent.TextPrivate); NotificationQueryRunner.RegisterForNotifications(ServerNotifyRegisterEvent.TextServer); }