public async Task Disconnect() { #pragma warning disable 4014 FriendHandler.NotifyFriends(this, false); #pragma warning restore 4014 Connected = false; try { await ClientHandler.Remove(this); ActiveTrade?.Kill(); ActiveBattle?.Kill($"{Username} disconnected"); if (QueuedTier != Tiers.Null) { await RandomBattles.RemoveRandom(this); } await WonderTrade.WonderTradeHandler.DeleteFromClient(this); await SendMessage("<DSC>", true); ActualCient.Close(); } catch (Exception e) { Logger.Logger.Log(e.ToString()); } }
internal async Task Login(string username, string password) { var result = await Database.DbAuthentication.Login(username, password, this); if (result == Database.LoginResult.Okay) { Username = username.ToLower(); LoggedIn = true; } if (_version.Major == 6 && _version.Minor == 84 && Admin == false) { //Ban if user logged in with a debug client, while not being an Admin #pragma warning disable 4014 Database.DbUserManagement.Ban(UserId); Database.DBWarnLog.LogWarning(UserId, "Automatic ban: Tried to log in with Debug build."); #pragma warning restore 4014 await SendMessage($"<LOG result={(int) Database.LoginResult.Banned}>"); return; } await SendMessage($"<LOG result={(int) result}>"); Friends = await Database.DbFriendHandler.GetFriends(this); //We encode each name into base64 to prevent commas in names from breaking stuff var compilefriends = string.Join(",", Friends.Select(x => Utilities.Encoding.Base64Encode(x.ToString()))); var onlinestring = Friends.Aggregate("", (current, friend) => current + (((ClientHandler.GetClient(friend)) == null) ? "0" : "1")); await SendMessage($"<FRIENDLIST friends={compilefriends} online={onlinestring}>"); #pragma warning disable 4014 FriendHandler.NotifyFriends(this, true); #pragma warning restore 4014 }
public static async Task DenyFriendRequest(Client client, CommandHandler command) { await FriendHandler.DenyRequest(client, command.Data["user"]); }
public static async Task RemoveFriendRequest(Client client, CommandHandler command) { await FriendHandler.RemoveFriend(client, command.Data["user"]); }