Пример #1
0
        public void TestConnections()
        {
            var p          = new PasswordAuthProvider(new Uri("http://localhost:9001/"));
            var adminToken = p.Login(new PasswordAuthRequest <PasswordAuthData>()
            {
                RequestData = new PasswordAuthData()
                {
                    Password = "******", Usename = "admin"
                }
            }).Result;

            var connectionsList = new PasswordOAuthContext[10000];

            for (int conn = 0; conn < 10000; conn++)
            {
                try
                {
                    var registerRes = Register(adminToken, conn).Result;
                }
                catch (Exception ex)
                {
                    Debug.Write(ex.Message);
                }

                connectionsList[conn] = PostAuth(conn).Result;
            }
            Array.ForEach(new[] { 1, 10, 100, 1000, 10000 }, connectionsNumber =>
            {
                Debug.WriteLine("Connections number: {0}", connectionsNumber);

                var sw = Stopwatch.StartNew();
                for (int i = 0; i < connectionsNumber; i++)
                {
                    var x = GetData(connectionsList[i]).Result;
                }
                Debug.WriteLine("Single: {0}", sw.Elapsed);
                Debug.WriteLine("");
            });

            Array.ForEach(new[] { 1, 10, 100, 1000, 10000 }, connectionsNumber =>
            {
                Debug.WriteLine("Connections number: {0}", connectionsNumber);
                var sw = Stopwatch.StartNew();
                List <Task> taskList = new List <Task>();
                for (var i = 0; i < connectionsNumber; ++i)
                {
                    taskList.Add(GetData(connectionsList[i]));
                }
                Task.WhenAll(taskList);
                Debug.WriteLine("Parallel: {0}", sw.Elapsed);
                Debug.WriteLine("");
            });
        }
Пример #2
0
        public static ErrorCodes?UserLogout(PasswordOAuthContext session)
        {
            var authApi = new AuthApiClient(session);

            try
            {
                var result = authApi.Logout().Result;
            }
            catch (AggregateException loginException)
            {
                return(Program.GameRunner.HandleClientException(loginException.InnerException as IClientException <ErrorData>));
            }
            return(null);
        }
Пример #3
0
        private async static Task <object> Register(PasswordOAuthContext token, int index)
        {
            var authApi = new AuthApiClient(new PasswordOAuthContext()
            {
                BaseUri = new Uri("http://localhost:9001")
            });


            return(await authApi.Register(new RegisterAccountModel()
            {
                Login = "******" + index,
                Password = "******",
                ConfirmPassword = "******"
            }));
        }
Пример #4
0
        public AdminConsole(string user, string password, PasswordOAuthContext serverContext,
                            IAdminController adminManagerClient, string[] serversList, int servicePort)
        {
            _user          = user;
            _password      = password;
            _serverContext = serverContext;
            _serversList   = serversList;
            _servicePort   = servicePort;


            _statisticsUpdateTimer          = new Timer(5000);
            _statisticsUpdateTimer.Elapsed += GetStatisticsCallback;

            SetAdminClient(adminManagerClient);
            InitMenu();
        }
Пример #5
0
        private static async Task <GameDataModel> GetData(PasswordOAuthContext token)
        {
            var gameClient = new GameApiClient(token);

            return(await gameClient.GetGameDataAsync());
        }
Пример #6
0
 public static IRatingController GetRatingClient(PasswordOAuthContext session)
 {
     return(new RatingApiClient(session));
 }
Пример #7
0
 public static IServerController GetServerInfoClient(PasswordOAuthContext session)
 {
     return(new ServerInfoClient(session));
 }
Пример #8
0
 public static IAdminController GetAdminClient(PasswordOAuthContext session)
 {
     return(new AdminApiClient(session));
 }
Пример #9
0
 public static IGameApiController GetGameClient(PasswordOAuthContext session)
 {
     return(new GameApiClient(session));
 }
Пример #10
0
 public GameRunner(string user, PasswordOAuthContext serverContext, IGameApiController game)
 {
     ServerContext = serverContext;
     User          = user;
     _game         = game;
 }