public void Login()
        {
            var login = _serverQueryClient.Login(QueryUserName, QueryPassword).Result;

            Console.WriteLine("login {0} {1} {2}", login.Success, login.ErrorId, login.ErrorMessage);

            ServerQueryBaseResult use = _serverQueryClient.Use(UseServerBy.ServerId, 1).Result;

            Console.WriteLine("use {0} {1} {2}", use.Success, use.ErrorId, use.ErrorMessage);

            _serverQueryClient.KeepAlive(TimeSpan.FromMinutes(2));

            var registerTextChannel = _serverQueryClient.ServerNotifyRegister(Event.server).Result;

            Console.WriteLine("registerTextChannel {0} {1} {2}", registerTextChannel.Success, registerTextChannel.ErrorId, registerTextChannel.ErrorMessage);

            _serverQueryClient.NotifyServerEdited += (sender, result) =>
            {
                Console.WriteLine("HOAL!");
            };

            var clientList = _serverQueryClient.ClientList().Result;

            Console.WriteLine("clientList {0} {1} [x{2}]", clientList.Success, clientList.ErrorId, clientList.Values?.Count ?? 0);
        }
Beispiel #2
0
 static void Start()
 {
     Connect();
     Login();
     Use();
     Subscribe();
     client.KeepAlive(TimeSpan.FromMinutes(2));
 }
Beispiel #3
0
        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;
        }
Beispiel #5
0
        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);
                }
            }
        }