Exemplo n.º 1
0
        /*
         */
        public static void Main(string[] args)
        {
            TeamspeakClient client = new TeamspeakClient("localhost", 25639, new CancellationToken());

            client.ConnectClient();

            Thread.Sleep(1000);

            client.AuthorizeClient("CNP7-MPR4-DXYT-92SE-GEXT-3N2F");

            //List<Client> clients = client.GetClientList();

            RegisterTestEvent(client, typeof(NotifyTalkStatusChangeEvent));
            RegisterTestEvent(client, typeof(NotifyBanListEvent));
            RegisterTestEvent(client, typeof(NotifyMessageEvent));
            RegisterTestEvent(client, typeof(NotifyClientMovedEvent));

            (int clientId, int channelId) = client.GetWhoAmI();

            Console.WriteLine($"     ===> My Client ID:  {clientId}");
            Console.WriteLine($"     ===> My Channel ID: {channelId}");

            List <Client> inMyChannel = client.GetClientsInChannel(channelId);

            Utils.PrintClientList(inMyChannel);

            Console.WriteLine($"All Clients:");
            List <Client> clients = client.GetClientList(false);

            Utils.PrintClientList(clients);

            //Task.Run(() => {
            //    while (true) {
            //        Console.WriteLine("Command 'whoami': "+client.SendCommandSync("whoami"));
            //        Thread.Sleep(4000);
            //    }
            //});
            //Thread.Sleep(0);
            //Task.Run(() => {
            //    while (true) {
            //        Console.WriteLine("Command 'clientlist': "+client.SendCommandSync("clientlist"));
            //        Thread.Sleep(4000);
            //    }
            //});


            Console.ReadKey();
        }
Exemplo n.º 2
0
 public static void RegisterTestEvent(TeamspeakClient client, Type eventType)
 {
     client.RegisterEventCallback(eventType, (genericEvt) => {
         Console.WriteLine($"Got event: {genericEvt}");
     });
 }