/// <summary> /// Notify Friends of this Player that he entered Game /// </summary> /// <param name="Player">GamePlayer to notify to friends</param> private void NotifyPlayerFriendsEnteringGame(GamePlayer Player) { var playerName = Player.Name; var playerUpdate = new [] { playerName }; foreach (GamePlayer friend in PlayersFriendsListsCache.Where(kv => kv.Value.Contains(playerName)).Select(kv => kv.Key)) { friend.Out.SendAddFriends(playerUpdate); } }
/// <summary> /// Notify Friends of this Player that he exited Game /// </summary> /// <param name="Player">GamePlayer to notify to friends</param> private void NotifyPlayerFriendsExitingGame(GamePlayer Player) { var playerName = Player.Name; var playerUpdate = new [] { playerName }; foreach (GamePlayer friend in PlayersFriendsListsCache.Where(kv => kv.Value.Contains(playerName)).Select(kv => kv.Key)) { friend.Out.SendRemoveFriends(playerUpdate); } var offline = new FriendStatus(Player.Name, Player.Level, Player.CharacterClass.ID, DateTime.Now); PlayersFriendsStatusCache.FreezeWhile(dict => { foreach (var list in dict.Where(kv => kv.Value.Any(frd => frd.Name == Player.Name)).ToArray()) { dict[list.Key] = list.Value.Where(frd => frd.Name != Player.Name).Concat(new [] { offline }).ToArray(); } }); }