Пример #1
0
        static void Dispose()
        {
            ServerQueryBaseResult unregister = client.ServerNotifyUnregister().Result;

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

            ServerQueryBaseResult logout = client.Logout().Result;

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

            ServerQueryBaseResult quit = client.Quit().Result;

            Console.WriteLine("quit {0} {1} {2}", quit.Success, quit.ErrorId, quit.ErrorMessage);
        }
Пример #2
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;
        }
Пример #4
0
 public void Stop()
 {
     ServerQueryBaseResult unregister = client.ServerNotifyUnregister().Result;
     ServerQueryBaseResult logout     = client.Logout().Result;
     ServerQueryBaseResult quit       = client.Quit().Result;
 }