public void Connect()
        {
            // do not connect when already connected or during connection establishing
            if (QueryDispatcher != null)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(Model.ServerAddress))
            {
                MessageBox.Show("Please provide a server address!");
                return;
            }

            if (!Model.ServerPort.HasValue)
            {
                MessageBox.Show("Please provide a valid query port!");
                return;
            }

            Model.ConnectionState                    = ConnectionState.Connecting;
            QueryDispatcher                          = new AsyncTcpDispatcher(Model.ServerAddress, Model.ServerPort.Value);
            QueryDispatcher.BanDetected             += QueryDispatcher_BanDetected;
            QueryDispatcher.ReadyForSendingCommands += QueryDispatcher_ReadyForSendingCommands;
            QueryDispatcher.ServerClosedConnection  += QueryDispatcher_ServerClosedConnection;
            QueryDispatcher.SocketError             += QueryDispatcher_SocketError;
            QueryDispatcher.Connect();
        }
Exemple #2
0
        public void Connect()
        {
            // do not connect when already connected or during connection establishing
            if (QueryDispatcher != null)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(ServerAddressTextBox.Text))
            {
                MessageBox.Show("Please provide a server address!");
                return;
            }

            ushort port;


            if (!ushort.TryParse(ServerPort.Text, out port))
            {
                MessageBox.Show("Please provide a valid query port!");
                return;
            }

            UpdateUI(ConnectionState.Connecting);
            QueryDispatcher                          = new AsyncTcpDispatcher(ServerAddressTextBox.Text.Trim(), port);
            QueryDispatcher.BanDetected             += QueryDispatcher_BanDetected;
            QueryDispatcher.ReadyForSendingCommands += QueryDispatcher_ReadyForSendingCommands;
            QueryDispatcher.ServerClosedConnection  += QueryDispatcher_ServerClosedConnection;
            QueryDispatcher.SocketError             += QueryDispatcher_SocketError;
            QueryDispatcher.Connect();
        }
Exemple #3
0
 private void Connect()
 {
     QueryDispatcher                          = new AsyncTcpDispatcher(ServerAddress, Port);
     QueryDispatcher.BanDetected             += QueryDispatcher_BanDetected;
     QueryDispatcher.ReadyForSendingCommands += QueryDispatcher_ReadyForSendingCommands;
     QueryDispatcher.ServerClosedConnection  += QueryDispatcher_ServerClosedConnection;
     QueryDispatcher.SocketError             += QueryDispatcher_SocketError;
     QueryDispatcher.Connect();
 }
Exemple #4
0
 public Addon(MySQLInstance _sql, ServerQueryInstance _serverq, ServerInfo _serverinfo)
 {
     sql              = _sql;
     serverq          = _serverq;
     queryRunner      = serverq.queryRunner;
     atd              = serverq.atd;
     serverinfo       = _serverinfo;
     eventDumpStrings = new List <string>();
 }
 public void Run()
 {
     _stopwatch.Start();
     QueryDispatcher                          = new AsyncTcpDispatcher(Ts3Config.Host, Ts3Config.Port);
     QueryDispatcher.BanDetected             += QueryDispatcher_BanDetected;
     QueryDispatcher.ReadyForSendingCommands += QueryDispatcher_ReadyForSendingCommands;
     QueryDispatcher.ServerClosedConnection  += QueryDispatcher_ServerClosedConnection;
     QueryDispatcher.SocketError             += QueryDispatcher_SocketError;
     QueryDispatcher.Connect();
     Connected = true;
 }
        /// <summary>
        /// Inits the credential.
        /// </summary>
        private void InitCredential()
        {
            TcpDispatcher = new SyncTcpDispatcher(BotInstance.Settings);
            QueryRunner   = new QueryRunner(TcpDispatcher);
            QueryRunner.Login(BotInstance.Settings.TeamSpeak.Username, BotInstance.Settings.TeamSpeak.Password);
            if (BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault() > 0)
            {
                QueryRunner.SelectVirtualServerByPort(BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault());
            }
            else
            {
                QueryRunner.SelectVirtualServerById(BotInstance.Settings.TeamSpeak.Instance.GetValueOrDefault());
            }
            Self = QueryRunner.SendWhoAmI();

            WorkerTcpDispatcher = new SyncTcpDispatcher(BotInstance.Settings);
            WorkerQueryRunner   = new QueryRunner(WorkerTcpDispatcher);
            WorkerQueryRunner.Login(BotInstance.Settings.TeamSpeak.Username, BotInstance.Settings.TeamSpeak.Password);

            if (BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault() > 0)
            {
                WorkerQueryRunner.SelectVirtualServerByPort(BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault());
            }
            else
            {
                WorkerQueryRunner.SelectVirtualServerById(BotInstance.Settings.TeamSpeak.Instance.GetValueOrDefault());
            }

            WorkerQueryRunner.UpdateCurrentQueryClient(new ClientModification {
                Nickname = BotInstance.Settings.Global.BotNickname
            });
            SelfWorker = WorkerQueryRunner.SendWhoAmI();
            WorkerQueryRunner.AddLogEntry(new LogEntryLight(LogLevel.Info, string.Format("TS3-Bot '{0}' connected.", BotInstance.Settings.Global.BotNickname)));

            NotificationTcpDispatcher = new AsyncTcpDispatcher(BotInstance.Settings);
            NotificationQueryRunner   = new QueryRunner(NotificationTcpDispatcher);

            NotificationTcpDispatcher.ServerClosedConnection             += notificationDispatcher_ServerClosedConnection;
            NotificationTcpDispatcher.ReadyForSendingCommands            += notificationDispatcher_ReadyForSendingCommands;
            NotificationQueryRunner.Notifications.ClientJoined           += BotInstance.Notifications_ClientJoined;
            NotificationQueryRunner.Notifications.ClientMoved            += BotInstance.Notifications_ClientMoved;
            NotificationQueryRunner.Notifications.ClientMoveForced       += BotInstance.Notifications_ClientMoveForced;
            NotificationQueryRunner.Notifications.ClientDisconnect       += BotInstance.Notifications_ClientDisconnect;
            NotificationQueryRunner.Notifications.ClientConnectionLost   += BotInstance.Notifications_ClientConnectionLost;
            NotificationQueryRunner.Notifications.ServerMessageReceived  += BotInstance.Notifications_MessageReceived;
            NotificationQueryRunner.Notifications.ChannelMessageReceived += BotInstance.Notifications_MessageReceived;
            NotificationQueryRunner.Notifications.ClientMessageReceived  += BotInstance.Notifications_MessageReceived;

            TcpDispatcher.Connect();
            WorkerTcpDispatcher.Connect();
            NotificationTcpDispatcher.Connect();
            Initialized = true;
        }
Exemple #7
0
            // Öffne die Verbindung zum TeamSpeak Server
            public void OpenConnection()
            {
                // Logging
                Logging.Log("Baue Verbindung zu " + host + ":" + queryPort + " auf...");

                // Verbindung
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
                tcpSocket = new AsyncTcpDispatcher(host, queryPort);
                tcpSocket.ReadyForSendingCommands += OnReadyToSendCommands;
                tcpSocket.BanDetected             += OnBanDetected;
                tcpSocket.NotificationReceived    += OnNotificationReceived;
                tcpSocket.ServerClosedConnection  += OnServerClosedConnection;
                tcpSocket.Connect();
            }
        public void UserInitialize(CoreList AddonInjections)
        {
            if (Nickname == null)
            {
                if (this.Subscriber.BotNickName == null)
                {
                    Nickname = Subscriber.AdminUsername;
                }
                else
                {
                    Nickname = Subscriber.BotNickName;
                }
            }

            this.connectionChange = new AutoResetEvent(false);
            AsyncTcpDispatcher    = new AsyncTcpDispatcher(Subscriber.ServerIp, (ushort)Subscriber.ServerPort);
            QueryRunner           = new QueryRunner(AsyncTcpDispatcher);

            //atd.ServerClosedConnection += atd_ServerClosedConnection;
            AsyncTcpDispatcher.ReadyForSendingCommands += atd_ReadyForSendingCommands;
            AsyncTcpDispatcher.SocketError             += atd_SocketError;

            Connect();

            SimpleResponse loginResult = Login();

            if (loginResult.IsBanned)
            {
                logger.Info("Login failure due to ban: {0}", loginResult.ResponseText);
            }
            else if (loginResult.IsErroneous)
            {
                logger.Info("Login failure due to error: {0}", loginResult.ResponseText);
            }
            else
            {
                SendSetNameCmd();

                SelectServer(Subscriber);

                SendSetNameCmd();

                UpdateServerUniqueId();

                whoAmI = QueryRunner.SendWhoAmI();

                RegisterEvents();
            }
        }
Exemple #9
0
        public void Connect()
        {
            // do not connect when already connected or during connection establishing
            if (QueryDispatcher != null)
            {
                return;
            }

            Model.ConnectionState                    = ConnectionState.Connecting;
            QueryDispatcher                          = new AsyncTcpDispatcher("localhost", 25639);
            QueryDispatcher.BanDetected             += QueryDispatcher_BanDetected;
            QueryDispatcher.ReadyForSendingCommands += QueryDispatcher_ReadyForSendingCommands;
            QueryDispatcher.ServerClosedConnection  += QueryDispatcher_ServerClosedConnection;
            QueryDispatcher.SocketError             += QueryDispatcher_SocketError;
            QueryDispatcher.NotificationReceived    += QueryDispatcher_NotificationReceived;
            QueryDispatcher.Connect();
        }
 private void Connect()
 {
     API.Log(API.LogType.Debug, "Teamspeak.ddl: Connecting");
     // do not connect when already connected or during connection establishing
     if (QueryDispatcher != null)
     {
         API.Log(API.LogType.Debug, "Teamspeak.ddl: QueryDispatcher not null");
         return;
     }
     lock (ThreadLocker)
     {
         Connected                                = ConnectionState.Connecting;
         QueryDispatcher                          = new AsyncTcpDispatcher("localhost", 25639);
         QueryDispatcher.BanDetected             += QueryDispatcher_BanDetected;
         QueryDispatcher.ReadyForSendingCommands += QueryDispatcher_ReadyForSendingCommands;
         QueryDispatcher.ServerClosedConnection  += QueryDispatcher_ServerClosedConnection;
         QueryDispatcher.SocketError             += QueryDispatcher_SocketError;
         QueryDispatcher.NotificationReceived    += QueryDispatcher_NotificationReceived;
         API.Log(API.LogType.Debug, "Teamspeak.ddl: linked events");
         QueryDispatcher.Connect();
         Keep_Alive_Timer.Start();
     }
 }
Exemple #11
0
            // Öffne die Verbindung zum TeamSpeak Server
            public void OpenConnection()
            {
                // Logging
                Logging.Log("Baue Verbindung zu " + host + ":" + queryPort + " auf...");

                // Verbindung
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
                tcpSocket = new AsyncTcpDispatcher(host, queryPort);
                tcpSocket.ReadyForSendingCommands += OnReadyToSendCommands;
                tcpSocket.BanDetected += OnBanDetected;
                tcpSocket.NotificationReceived += OnNotificationReceived;
                tcpSocket.ServerClosedConnection += OnServerClosedConnection;
                tcpSocket.Connect();
            }
        /// <summary>
        /// Inits the credential.
        /// </summary>
        private void InitCredential()
        {
            TcpDispatcher = new SyncTcpDispatcher(BotInstance.Settings);
            QueryRunner = new QueryRunner(TcpDispatcher);
            QueryRunner.Login(BotInstance.Settings.TeamSpeak.Username, BotInstance.Settings.TeamSpeak.Password);
            if (BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault() > 0)
                QueryRunner.SelectVirtualServerByPort(BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault());
            else
                QueryRunner.SelectVirtualServerById(BotInstance.Settings.TeamSpeak.Instance.GetValueOrDefault());
            Self = QueryRunner.SendWhoAmI();

            WorkerTcpDispatcher = new SyncTcpDispatcher(BotInstance.Settings);
            WorkerQueryRunner = new QueryRunner(WorkerTcpDispatcher);
            WorkerQueryRunner.Login(BotInstance.Settings.TeamSpeak.Username, BotInstance.Settings.TeamSpeak.Password);

            if (BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault() > 0)
                WorkerQueryRunner.SelectVirtualServerByPort(BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault());
            else
                WorkerQueryRunner.SelectVirtualServerById(BotInstance.Settings.TeamSpeak.Instance.GetValueOrDefault());

            WorkerQueryRunner.UpdateCurrentQueryClient(new ClientModification { Nickname = BotInstance.Settings.Global.BotNickname });
            SelfWorker = WorkerQueryRunner.SendWhoAmI();
            WorkerQueryRunner.AddLogEntry(new LogEntryLight(LogLevel.Info, string.Format("TS3-Bot '{0}' connected.", BotInstance.Settings.Global.BotNickname)));

            NotificationTcpDispatcher = new AsyncTcpDispatcher(BotInstance.Settings);
            NotificationQueryRunner = new QueryRunner(NotificationTcpDispatcher);

            NotificationTcpDispatcher.ServerClosedConnection += notificationDispatcher_ServerClosedConnection;
            NotificationTcpDispatcher.ReadyForSendingCommands += notificationDispatcher_ReadyForSendingCommands;
            NotificationQueryRunner.Notifications.ClientJoined += BotInstance.Notifications_ClientJoined;
            NotificationQueryRunner.Notifications.ClientMoved += BotInstance.Notifications_ClientMoved;
            NotificationQueryRunner.Notifications.ClientMoveForced += BotInstance.Notifications_ClientMoveForced;
            NotificationQueryRunner.Notifications.ClientDisconnect += BotInstance.Notifications_ClientDisconnect;
            NotificationQueryRunner.Notifications.ClientConnectionLost += BotInstance.Notifications_ClientConnectionLost;
            NotificationQueryRunner.Notifications.ServerMessageReceived += BotInstance.Notifications_MessageReceived;
            NotificationQueryRunner.Notifications.ChannelMessageReceived += BotInstance.Notifications_MessageReceived;
            NotificationQueryRunner.Notifications.ClientMessageReceived += BotInstance.Notifications_MessageReceived;

            TcpDispatcher.Connect();
            WorkerTcpDispatcher.Connect();
            NotificationTcpDispatcher.Connect();
            Initialized = true;
        }