Exemplo n.º 1
0
 public override void Connect()
 {
     if (!tsBaseClient.Connected)
     {
         tsQueryClient.Connect(new ConnectionData()
         {
             Hostname = connectionData.host, Port = connectionData.port
         });
         tsQueryClient.Login(connectionData.user, connectionData.passwd);
         tsQueryClient.UseServer(1);
         try { tsQueryClient.ChangeName("TS3AudioBot"); }
         catch (Ts3CommandException) { Log.Write(Log.Level.Warning, "TS3AudioBot name already in use!"); }
     }
 }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            var query = new Ts3QueryClient(EventDispatchType.DoubleThread);
            var con   = new ConnectionData()
            {
                Address = "127.0.0.1"
            };

            query.Connect(con);
            var use = query.UseServer(1);

            Console.WriteLine("Use: {0}", use.Ok);
            var who = query.WhoAmI();

            Console.WriteLine("Who: {0}", who.Ok ? (object)who.Value : who.Error.ErrorFormat());

            while (true)
            {
                var line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }
                var dict = query.SendCommand <ResponseDictionary>(new Ts3RawCommand(line));
                if (dict.Ok)
                {
                    foreach (var item in dict.Value)
                    {
                        foreach (var val in item)
                        {
                            Console.Write("{0}={1}", val.Key, val.Value);
                        }
                        Console.WriteLine();
                    }
                }
                else
                {
                    Console.WriteLine(dict.Error.ErrorFormat());
                }
            }
        }