protected void ConnectButton_OnClick(object sender, EventArgs e)
        {
            ResultLabel.Text = null;
            ErrorLabel.Text = null;

            string host = ServerAddressTextBox.Text.Trim();
            ushort port = Convert.ToUInt16(ServerPortTextBox.Text);

            try
            {
                using (QueryRunner queryRunner = new QueryRunner(new SyncTcpDispatcher(host, port)))  // host and port
                {
                    // connection to the TS3-Server is established with the first query command

                    VersionResponse versionResponse = queryRunner.GetVersion();

                    if (versionResponse.IsErroneous)
                    {
                        ErrorLabel.Text = "Could not get server version: " + versionResponse.ErrorMessage;
                        return;
                    }

                    ResultLabel.Text = string.Format("Server version:<br>Platform: {0}<br>Version: {1}<br>Build: {2}", versionResponse.Platform, versionResponse.Version, versionResponse.Build);
                }

            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.Message;
            }
        }
Example #2
0
    private void QueryDispatcher_ReadyForSendingCommands(object sender, System.EventArgs e)
    {
      // you can only run commands on the queryrunner when this event has been raised first!
      QueryRunner = new QueryRunner(QueryDispatcher);

      VersionResponse versionResponse = QueryRunner.GetVersion();

      if (versionResponse.IsErroneous)
      {
        Console.WriteLine("Could not get server version: " + versionResponse.ErrorMessage);
        return;
      }

      Console.WriteLine("Server version:\n\nPlatform: {0}\nVersion: {1}\nBuild: {2}", versionResponse.Platform, versionResponse.Version, versionResponse.Build);
    }
Example #3
0
        private void QueryDispatcher_ReadyForSendingCommands(object sender, EventArgs e)
        {
            UpdateUI(ConnectionState.Connected);
            // you can only run commands on the queryrunner when this event has been raised first!
            QueryRunner = new QueryRunner(QueryDispatcher);

            VersionResponse versionResponse = QueryRunner.GetVersion();

            if (versionResponse.IsErroneous)
            {
                MessageBox.Show("Could not get server version: " + versionResponse.ErrorMessage);
                return;
            }

            MessageBox.Show(string.Format("Server version:\n\nPlatform: {0}\nVersion: {1}\nBuild: {2}", versionResponse.Platform, versionResponse.Version, versionResponse.Build));
        }