public void OnPing(ILoginClient client, PingPacket pingPacket) { if (!pingPacket.IsTimeOut) { _loginPacketFactory.SendPong(client, pingPacket.Time); } }
public AccountController() { _tokenContainer = new TokenContainer(); var apiClient = new ApiClient(HttpClientInstance.Instance, _tokenContainer); _loginClient = new LoginClient(apiClient); }
public static Task <LobbyItem[]> GetLobbyRoomsAsync(this Client client, ILoginClient loginClient, string roomType) { return(client.Multiplayer .ListRoomsAsync(roomType, null, 0, 0) .Then(r => r.Result .Select(room => new LobbyItem(loginClient, room)) .ToArray()) .ToSafeTask()); }
public static Task<LobbyItem[]> GetLobbyRoomsAsync(this Client client, ILoginClient loginClient, string roomType) { return client.Multiplayer .ListRoomsAsync(roomType, null, 0, 0) .Then(r => r.Result .Select(room => new LobbyItem(loginClient, room)) .ToArray()) .ToSafeTask(); }
public LobbyItem(ILoginClient client, RoomInfo roomInfo) { this._client = client; this.Id = roomInfo.Id; this.Online = roomInfo.OnlineUsers; foreach (var data in roomInfo.RoomData) { switch (data.Key) { case "name": this.Name = data.Value; break; case "plays": this.Plays = int.Parse(data.Value); break; case "Likes": this.Likes = int.Parse(data.Value); break; case "Favorites": this.Favorites = int.Parse(data.Value); break; case "description": this.Description = data.Value; break; case "openworld": this.OpenWorld = bool.Parse(data.Value); break; case "needskey": this.NeedsKey = (data.Value == "yep"); break; case "beta": this.Beta = int.Parse(data.Value); break; case "IsFeatured": this.Featured = bool.Parse(data.Value); break; case "IsCampaign": this.Campaign = bool.Parse(data.Value); break; case "LobbyPreviewEnabled": this.LobbyPreviewEnabled = bool.Parse(data.Value); break; } } }
/// <summary> /// Sends an authentication failed packet to the client. /// </summary> /// <param name="client">Client.</param> /// <param name="error">Authentication error type.</param> /// <param name="reason">Authentication error reason.</param> /// <param name="disconnectClient">A boolean value that indicates if we disconnect the client or not.</param> private void AuthenticationFailed(ILoginClient client, ErrorType error, string reason, bool disconnectClient = true) { _logger.LogWarning($"Unable to authenticate user from {client.Socket.RemoteEndPoint}. Reason: {reason}"); _loginPacketFactory.SendLoginError(client, error); if (disconnectClient) { client.Disconnect(); } }
/// <inheritdoc /> public void SendLoginError(ILoginClient client, ErrorType error) { using (var packet = new FFPacket()) { packet.WriteHeader(PacketType.ERROR); packet.Write((int)error); client.Send(packet); } }
/// <inheritdoc /> public void SendPong(ILoginClient client, int time) { using (var packet = new FFPacket()) { packet.WriteHeader(PacketType.PING); packet.Write(time); client.Send(packet); } }
/// <inheritdoc /> public void SendWelcome(ILoginClient client, uint sessionId) { using (var packet = new FFPacket()) { packet.WriteHeader(PacketType.WELCOME); packet.Write(sessionId); client.Send(packet); } }
public void OnCloseExistingConnection(ILoginClient client, CloseConnectionPacket closeConnectionPacket) { var otherConnectedClient = _loginServer.GetClientByUsername(closeConnectionPacket.Username); if (otherConnectedClient == null) { _logger.LogWarning($"Cannot find user with username '{closeConnectionPacket.Username}'."); return; } // TODO: disconnect client from server and ISC. }
public void OnCertify(ILoginClient client, CertifyPacket certifyPacket) { if (certifyPacket.BuildVersion != _loginConfiguration.BuildVersion) { AuthenticationFailed(client, ErrorType.ILLEGAL_VER, "bad client build version"); return; } DbUser user = _database.Users.FirstOrDefault(x => x.Username.Equals(certifyPacket.Username)); AuthenticationResult authenticationResult = Authenticate(user, certifyPacket.Password); switch (authenticationResult) { case AuthenticationResult.BadUsername: AuthenticationFailed(client, ErrorType.FLYFF_ACCOUNT, "bad username"); break; case AuthenticationResult.BadPassword: AuthenticationFailed(client, ErrorType.FLYFF_PASSWORD, "bad password"); break; case AuthenticationResult.AccountSuspended: // TODO break; case AuthenticationResult.AccountTemporarySuspended: // TODO break; case AuthenticationResult.AccountDeleted: AuthenticationFailed(client, ErrorType.ILLEGAL_ACCESS, "logged in with deleted account"); break; case AuthenticationResult.Success: if (_loginServer.IsClientConnected(certifyPacket.Username)) { AuthenticationFailed(client, ErrorType.DUPLICATE_ACCOUNT, "client already connected", disconnectClient: false); return; } user.LastConnectionTime = DateTime.UtcNow; _database.Users.Update(user); _database.SaveChanges(); _loginPacketFactory.SendServerList(client, certifyPacket.Username, _coreServer.GetConnectedClusters()); client.SetClientUsername(certifyPacket.Username); _logger.LogInformation($"User '{client.Username}' logged succesfully from {client.Socket.RemoteEndPoint}."); break; default: break; } }
public App(IConfiguration config, IConsole console, ICountryClient countryClient, IInitialAppClient initialAppClient, ILoginClient loginClient, IBatteryStatusClient batteryStatusClient) { _config = config; _console = console; _countryClient = countryClient; _initialAppClient = initialAppClient; _loginClient = loginClient; _batteryStatusClient = batteryStatusClient; }
public ApplicationManager(ILoginClient i_LoginClient) { m_loginClient = InputGuard.CheckNullArgument(i_LoginClient, nameof(i_LoginClient)); m_ExitSignal = false; try { m_AppSettings = AppXmlSettingsHandler.Instance.LoadSettingsFromFile(); } catch { useDefaultSettings(); } }
protected Hashtable GenParamHash(ILoginClient login, Profile profile) => new Hashtable { { "auth_player_name", login.Username }, { "version_name", "vanilla" }, { "game_directory", profile.GameDir }, { "assets_root", $"{profile.GameDir}/assets" }, { "assets_index_name", (string)vdata["assetIndex"]["id"] }, { "auth_uuid", login.ID }, { "auth_access_token", login.AccessToken }, { "user_type", "mojang" }, { "version_type", (string)vdata["type"] }, { "resolution_width", profile.Width }, { "resolution_height", profile.Height }, { "natives_directory", $"{VID}/{VID}-natives" }, { "launcher_name", "WTFMC" }, { "launcher_version", "" }, { "classpath", GenerateClasspath() } };
public ApiClient(HttpClient httpClient, IConfiguration configuration) { var apiConfigurations = new ApiConfigurations(); new ConfigureFromConfigurationOptions <ApiConfigurations>(configuration.GetSection("ApiConfigurations")) .Configure(apiConfigurations); _apiEndpoint = apiConfigurations.BaseURL; if (!_apiEndpoint.EndsWith("/")) { _apiEndpoint += "/"; } httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiConfigurations.Token); BasketClient = new BasketClient(_apiEndpoint, httpClient); ProductGroupClient = new ProductGroupClient(_apiEndpoint, httpClient); ProductClient = new ProductClient(_apiEndpoint, httpClient); LoginClient = new LoginClient(_apiEndpoint, httpClient); }
public override List <string> GenerateArgs(ILoginClient login, Profile profile) { List <string> arguments = new List <string>(); RuleReader rr = new RuleReader { Login = login }; Hashtable arghash = GenParamHash(login, profile); // Apply default parameters. JArray input = (JArray)vdata["arguments"]["game"]; foreach (JToken i in input) { if (i.HasValues) { rr.Execute((JArray)(i["rules"]), () => { if (i["value"].HasValues) { foreach (string v in i["value"]) { arguments.Add(new Formatter().Format(v, arghash)); } } else { arguments.Add(new Formatter().Format((string)i["value"], arghash)); } }); } else { // Boilerplate code found here... arguments.Add(new Formatter().Format((string)i, arghash)); } } return(arguments); }
private void SetUpLoginData(ILoginClient login) { if (login == null) { way.IsEnabled = true; access.Text = ""; access.Focusable = true; } access.Text = login.Username; if (login.LoginType == LoginType.Mojang) { way.IsEnabled = false; access.Focusable = false; way.SelectedIndex = 1; } else if (login.LoginType == LoginType.Offline) { way.IsEnabled = true; access.Focusable = true; way.SelectedIndex = 0; } ShowPassword(); }
/// <inheritdoc /> public void SendServerList(ILoginClient client, string username, IEnumerable <ClusterServerInfo> clusters) { using (var packet = new FFPacket()) { packet.WriteHeader(PacketType.SRVR_LIST); packet.Write(0); packet.Write <byte>(1); packet.Write(username); packet.Write(clusters.Sum(x => x.Worlds.Count) + clusters.Count()); foreach (ClusterServerInfo cluster in clusters) { packet.Write(-1); packet.Write(cluster.Id); packet.Write(cluster.Name); packet.Write(cluster.Host); packet.Write(0); packet.Write(0); packet.Write(1); packet.Write(0); foreach (WorldServerInfo world in cluster.Worlds) { packet.Write(cluster.Id); packet.Write(world.Id); packet.Write(world.Name); packet.Write(world.Host); packet.Write(0); packet.Write(0); packet.Write(1); packet.Write(100); // Capacity } } client.Send(packet); } }
public LobbyItem(ILoginClient client, RoomInfo roomInfo) { this._client = client; this.Id = roomInfo.Id; this.Online = roomInfo.OnlineUsers; foreach (var data in roomInfo.RoomData) { switch (data.Key) { case "name": this.Name = data.Value; break; case "plays": this.Plays = int.Parse(data.Value); break; case "woots": this.Woots = int.Parse(data.Value); break; case "owned": this.Owned = bool.Parse(data.Value); break; case "needskey": this.HasCode = (data.Value == "yep"); break; case "IsFeatured": this.Featured = bool.Parse(data.Value); break; } } }
public static Task CreateOpenWorldAsync(this ILoginClient client, string name) { return(client.CreateOpenWorldAsync(name, CancellationToken.None)); }
public static Task JoinRoomAsync(this ILoginClient client, string roomId) { return(client.JoinRoomAsync(roomId, CancellationToken.None)); }
public static void CreateOpenWorld(this ILoginClient client, string name, CancellationToken ct) { client.CreateOpenWorldAsync(name, ct).WaitEx(); }
public static void JoinRoom(this ILoginClient client, string roomId, CancellationToken ct) { client.JoinRoomAsync(roomId, ct).WaitEx(); }
public static PlayerData GetPlayerData(this ILoginClient client) { return(client.GetPlayerDataAsync().GetResultEx()); }
public static LobbyItem[] GetLobbyRooms(this ILoginClient client) { return(client.GetLobbyRoomsAsync().GetResultEx()); }
public static Task CreateOpenWorldAsync(this ILoginClient client, string name) { return(client.CreateOpenWorldAsync("OW" + GenerateUniqueRoomId(name), name)); }
public static DatabaseWorld LoadWorld(this ILoginClient client, string roomId) { return(client.LoadWorldAsync(roomId).GetResultEx()); }
public LoginModel(ILoginClient loginClient) { LoginClient = loginClient; }
public LoginWorkflow(ILoginRepository loginRepository, ILoginClient loginClient) { this.loginRepository = loginRepository; this.loginClient = loginClient; }
// nonasync public static void CreateJoinRoom(this ILoginClient client, string roomId) { client.CreateJoinRoomAsync(roomId).WaitEx(); }
// async ct public static Task CreateOpenWorldAsync(this ILoginClient client, string name, CancellationToken ct) { return(client.CreateJoinOpenWorldAsync("OW" + GenerateUniqueRoomId(name), name, ct)); }
public static void CreateOpenWorld(this ILoginClient client, string name) { client.CreateOpenWorldAsync(name).WaitEx(); }