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(""); }); }
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); }
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 = "******" })); }
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(); }
private static async Task <GameDataModel> GetData(PasswordOAuthContext token) { var gameClient = new GameApiClient(token); return(await gameClient.GetGameDataAsync()); }
public static IRatingController GetRatingClient(PasswordOAuthContext session) { return(new RatingApiClient(session)); }
public static IServerController GetServerInfoClient(PasswordOAuthContext session) { return(new ServerInfoClient(session)); }
public static IAdminController GetAdminClient(PasswordOAuthContext session) { return(new AdminApiClient(session)); }
public static IGameApiController GetGameClient(PasswordOAuthContext session) { return(new GameApiClient(session)); }
public GameRunner(string user, PasswordOAuthContext serverContext, IGameApiController game) { ServerContext = serverContext; User = user; _game = game; }