static void Connect() { client = new ServerQueryClient(cfg["server"]["address"], int.Parse(cfg["server"]["queryport"]), TimeSpan.FromSeconds(1)); ServerQueryBaseResult connected = client.Initialize().Result; Console.WriteLine("connected {0}", connected.Success); }
public bool Start() { client = new ServerQueryClient(Url, 10011, TimeSpan.FromSeconds(3)); try { ServerQueryBaseResult connected = client.Initialize().Result; if (connected.Success) { ServerQueryBaseResult login = client.Login(Login, Password).Result; if (login.Success) { ServerQueryBaseResult use = client.Use(UseServerBy.Port, 9987).Result; if (use.Success) { return(true); } } } } catch (Exception ex) { } return(false); }
public bool Start() { client = new ServerQueryClient(Url, 10011, TimeSpan.FromSeconds(3)); try { ServerQueryBaseResult connected = client.Initialize().Result; if (connected.Success) { ServerQueryBaseResult login = client.Login(Login, Password).Result; if (login.Success) { ServerQueryBaseResult use = client.Use(UseServerBy.Port, 9987).Result; if (use.Success) { return true; } } } } catch (Exception ex) { } return false; }
public void Connect() { _serverQueryClient = new ServerQueryClient(QueryHost, QueryPort, TimeSpan.FromSeconds(3)); _serverQueryClient.ConnectionClosed += (sender, eventArgs) => Console.WriteLine(":sadface:"); ServerQueryBaseResult connected = _serverQueryClient.Initialize().Result; Console.WriteLine("connected {0}", connected.Success); }
public async Task <bool> AddClient(string name, string groupName, string TSURL, string password) { client = new ServerQueryClient(TSURL, 10011, TimeSpan.FromSeconds(3)); try { ServerQueryBaseResult connected = client.Initialize().Result; if (connected.Success) { ServerQueryBaseResult login = client.Login("serveradmin", password).Result; if (login.Success) { ServerQueryBaseResult use = client.Use(UseServerBy.Port, 9987).Result; if (use.Success) { client.KeepAlive(TimeSpan.FromMinutes(2)); clientList = client.ClientList().Result; ClientInfoResult ClientInfo = clientList.Values.Where(m => m.ClientNickname == name).FirstOrDefault(); if (ClientInfo != null) { await GetDBID(ClientInfo.ClientUniqueIdentifier); await GetServerGroup(groupName); await AddClient(); Message = string.Format("User {0} successfully created on TS Server {1}.", name, TSURL); } else { SuccessType = AddSuccess.Fail; Message = string.Format("Could not find a valid user on {0}. Please make sure your nickname is {1} and try again.", TSURL, name); } } } } } catch (Exception ex) { SuccessType = AddSuccess.Fail; } finally { ServerQueryBaseResult unregister = client.ServerNotifyUnregister().Result; ServerQueryBaseResult logout = client.Logout().Result; ServerQueryBaseResult quit = client.Quit().Result; } return(true); }
public async Task<bool> AddClient(string name, string groupName, string TSURL, string password) { client = new ServerQueryClient(TSURL, 10011, TimeSpan.FromSeconds(3)); try { ServerQueryBaseResult connected = client.Initialize().Result; if (connected.Success) { ServerQueryBaseResult login = client.Login("serveradmin", password).Result; if (login.Success) { ServerQueryBaseResult use = client.Use(UseServerBy.Port, 9987).Result; if (use.Success) { client.KeepAlive(TimeSpan.FromMinutes(2)); clientList = client.ClientList().Result; ClientInfoResult ClientInfo = clientList.Values.Where(m => m.ClientNickname == name).FirstOrDefault(); if (ClientInfo != null) { await GetDBID(ClientInfo.ClientUniqueIdentifier); await GetServerGroup(groupName); await AddClient(); Message = string.Format("User {0} successfully created on TS Server {1}.", name, TSURL); } else { SuccessType = AddSuccess.Fail; Message = string.Format("Could not find a valid user on {0}. Please make sure your nickname is {1} and try again.", TSURL, name); } } } } } catch (Exception ex) { SuccessType = AddSuccess.Fail; } finally { ServerQueryBaseResult unregister = client.ServerNotifyUnregister().Result; ServerQueryBaseResult logout = client.Logout().Result; ServerQueryBaseResult quit = client.Quit().Result; } return true; }
public static void TeamSpeak(string param, Dictionary <string, CommandRecord> commandMap) { var TSclient = new ServerQueryClient("127.0.0.1", 10011, TimeSpan.Zero); TSclient.ConnectionClosed += (sender, eventArgs) => Logger.Write(":sadface:", LogLevel.Error); var init = TSclient.Initialize().Result; if (!init.Success) { Logger.Write($"TeamSpeak: {init.ErrorMessage}"); return; } var login = TSclient.Login("serveradmin", "CrneScCM").Result; if (!login.Success) { Logger.Write($"TeamSpeak: {login.ErrorMessage}"); return; } var use = TSclient.Use(UseServerBy.ServerId, 1).Result; if (!use.Success) { Logger.Write($"TeamSpeak: {use.ErrorMessage}"); return; } var clientList = TSclient.ClientList().Result; if (clientList.Success) { foreach (var client in clientList.Values) { if (!client.ClientNickname.Contains("serveradmin ")) { Logger.Write($"{client.ClientNickname}", LogLevel.Info); } } } Console.WriteLine("---"); }
public static void ConnectQueryAsync() { ServerQueryClient client = new ServerQueryClient(host, port, TimeSpan.FromSeconds(1)); ServerQueryBaseResult connected = client.Initialize().Result; if (connected.Success) { MessageBox.Show("connected"); } ServerQueryBaseResult login = client.Login(user, password).Result; if (!login.Success) { MessageBox.Show(login.ErrorMessage); } ServerQueryBaseResult use = client.Use(UseServerBy.Port, 10677).Result; if (!use.Success) { MessageBox.Show(use.ErrorMessage); } //client.SendTextMessage(TextMessageTargetMode.TextMessageTarget_CLIENT, 3, "please respond"); ClientListResult clientList = client.ClientList().Result; if (!clientList.Success) { MessageBox.Show(clientList.ErrorMessage); } client.NotifyTextMessage += (source, notification) => MessageBox.Show(notification.Invokername + ": " + notification.Msg); ServerQueryBaseResult registerTextChannel = client.ServerNotifyRegister(Event.textprivate).Result; if (!registerTextChannel.Success) { MessageBox.Show(registerTextChannel.ErrorMessage); } client.KeepAlive(TimeSpan.FromMinutes(10)); client.NotifyChannelEdited += (source, notification) => MessageBox.Show(notification.Invokername + ": " + notification.Invokerid); for (int i = 0; i < clientList.Values.Count; i++) { ClientInfoResult clientInfoResult = clientList.Values[i]; int id = clientInfoResult.ClientId; String name = clientInfoResult.ClientNickname; if (!name.Contains("Sharix")) { client.SendTextMessage(TextMessageTargetMode.TextMessageTarget_CLIENT, id, "you are a nonce lol"); MessageBox.Show(id.ToString() + " " + name); } } }