Skip to content

Instantly share code, notes, and snippets.

@Sennevds
Created May 15, 2020 09:52
Show Gist options
  • Save Sennevds/f95a1e3905cc0987c15a6ed3ea7d97bf to your computer and use it in GitHub Desktop.
Save Sennevds/f95a1e3905cc0987c15a6ed3ea7d97bf to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using TeamSpeak3QueryApi.Net.Specialized;
using TeamSpeak3QueryApi.Net.Specialized.Notifications;
using TeamSpeak3QueryApi.Net.Specialized.Responses;
namespace rcon
{
class Program
{
private static TeamSpeakClient _client;
static void Main(string[] args)
{
try
{
_client = ConnectToTeamspeak().Result;
while (true)
{
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
private static async Task<TeamSpeakClient> ConnectToTeamspeak()
{
try
{
var rc = new TeamSpeakClient(""); // Create rich client instance
await rc.Connect(); // connect to the server
await rc.Login("", ""); // login to do some stuff that requires permission
await rc.UseServer(1); // Use the server with id '1'
await rc.RegisterServerNotification();
rc.Subscribe<ClientEnterView>(Test);
return rc;
}
catch (Exception ex)
{
return null;
}
}
private static void Test(IReadOnlyCollection<ClientEnterView> obj)
{
if (_client != null)
{
var clients = GetClients().Result;
}
}
private static async Task<List<GetClientInfo>> GetClients()
{
try
{
var clients = await _client.GetClients(GetClientOptions.Uid);
return clients.ToList();
}
catch (Exception e)
{
Console.WriteLine(e);
throw e;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment