コード例 #1
0
        static async void DoItRich()
        {
            var loginData = File.ReadAllLines("..\\..\\..\\logindata.secret");

            var host     = loginData[0].Trim();
            var user     = loginData[1].Trim();
            var password = loginData[2].Trim();

            var rc = new TeamSpeakClient(host);

            await rc.Connect();

            await rc.Login(user, password);

            await rc.UseServer(1);

            await rc.WhoAmI();

            await rc.RegisterServerNotification();

            await rc.RegisterChannelNotification(30);

            var currentClients = await rc.GetClients();

            var fullClients = currentClients.Where(c => c.Type == ClientType.FullClient).ToList();
            //var fullClients = from c
            //                  in currentClients
            //                  where c.Type == ClientType.FullClient
            //                  select c;
            //fullClients.ForEach(async c=> await rc.KickClient(c, KickOrigin.Channel));
            await rc.KickClient(fullClients, KickOrigin.Channel);

            //foreach (var client in fullClients)
            //    await rc.KickClient(client.ClientId, KickTarget.Channel);

            // await rc.MoveClient(1, 1);
            // await rc.KickClient(1, KickTarget.Server);

            rc.Subscribe <ClientEnterView>(data => data.ForEach(c => Trace.WriteLine("Client " + c.NickName + " joined.")));
            rc.Subscribe <ClientLeftView>(data => data.ForEach(c => Trace.WriteLine("Client with id " + c.Id + " left (kicked/banned/left).")));
            rc.Subscribe <ServerEdited>(data => Debugger.Break());
            rc.Subscribe <ChannelEdited>(data => Debugger.Break());
            rc.Subscribe <ClientMoved>(data => Debugger.Break());

            Console.WriteLine("Done1");
        }
コード例 #2
0
        static async Task Main(string[] args)
        {
            var loginData = File.ReadAllLines("..\\..\\..\\logindata.secret");

            var host     = loginData[0].Trim();
            var user     = loginData[1].Trim();
            var password = loginData[2].Trim();

            var rc = new TeamSpeakClient(host);

            await rc.Connect();

            await rc.Login(user, password);

            await rc.UseServer(1);

            await rc.WhoAmI();

            await rc.RegisterServerNotification();

            await rc.RegisterChannelNotification(30);

            var serverGroups = await rc.GetServerGroups();

            var firstNormalGroup = serverGroups?.FirstOrDefault(s => s.ServerGroupType == ServerGroupType.NormalGroup);
            var groupClients     = await rc.GetServerGroupClientList(firstNormalGroup.Id);

            var currentClients = await rc.GetClients();

            var fullClients = currentClients.Where(c => c.Type == ClientType.FullClient).ToList();
            await rc.KickClient(fullClients, KickOrigin.Channel);

            // await rc.MoveClient(1, 1);
            // await rc.KickClient(1, KickTarget.Server);

            rc.Subscribe <ClientEnterView>(data => data.ForEach(c => Debug.WriteLine($"Client {c.NickName} joined.")));
            rc.Subscribe <ClientLeftView>(data => data.ForEach(c => Debug.WriteLine($"Client with id {c.Id} left (kicked/banned/left).")));
            rc.Subscribe <ServerEdited>(data => Debugger.Break());
            rc.Subscribe <ChannelEdited>(data => Debugger.Break());
            rc.Subscribe <ClientMoved>(data => Debugger.Break());

            Console.WriteLine("Done");
            Console.ReadLine();
        }