private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) { FriendsService.Delete(agentID, exfriendID.ToString()); FriendsService.Delete(exfriendID, agentID.ToString()); // Update local cache m_Friends[agentID].Friends = FriendsService.GetFriends(agentID); client.SendTerminateFriend(exfriendID); // // Notify the friend // // Try local if (LocalFriendshipTerminated(exfriendID)) { return; } PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); } } }
protected override FriendInfo[] GetFriendsFromService(IClientAPI client) { // m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name); Boolean agentIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(client.AgentId); } if (agentIsLocal) { return(base.GetFriendsFromService(client)); } FriendInfo[] finfos = new FriendInfo[0]; // Foreigner AgentCircuitData agentClientCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); if (agentClientCircuit != null) { string agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); finfos = FriendsService.GetFriends(agentUUI); m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, agentUUI); } // m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetFriendsFromService for {0}", client.Name); return(finfos); }
private void OnNewClient(IClientAPI client) { client.OnInstantMessage += OnInstantMessage; client.OnApproveFriendRequest += OnApproveFriendRequest; client.OnDenyFriendRequest += OnDenyFriendRequest; client.OnTerminateFriendship += OnTerminateFriendship; client.OnGrantUserRights += OnGrantUserRights; // Asynchronously fetch the friends list or increment the refcount for the existing // friends list Util.FireAndForget( delegate(object o) { lock (m_Friends) { UserFriendData friendsData; if (m_Friends.TryGetValue(client.AgentId, out friendsData)) { friendsData.Refcount++; } else { friendsData = new UserFriendData(); friendsData.PrincipalID = client.AgentId; friendsData.Friends = FriendsService.GetFriends(client.AgentId); friendsData.Refcount = 1; m_Friends[client.AgentId] = friendsData; } } } ); }
/// <summary> /// Prints all mutual friends between logged in user and user specified by email, /// if commandInfo containes option mutual = true and email is valid. /// Elsewhere it prints all friends of current user /// </summary> /// <param name="commandInfo"></param> /// <returns></returns> public override bool Execute(CommandInfo commandInfo) { Response <List <UserModel> > response = null; bool isEmail = !string.IsNullOrEmpty(commandInfo.Email); if (commandInfo.Mutual && isEmail) { response = friendsService.GetMutualFriends( Session.LoggedUser.Id, commandInfo.Email); if (response.IsSuccessful) { PrintFriends(response.ResultTask.Result); } return(true); } if (!(commandInfo.Mutual ^ !isEmail)) { IoService.Out.WriteLine(Resources.ErrorWrongParams); return(false); } response = friendsService.GetFriends(Session.LoggedUser.Id); if (response.IsSuccessful) { PrintFriends(response.ResultTask.Result); } return(true); }
private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List <UUID> callingCardFolders) { m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID); FriendsService.StoreFriend(agentID, friendID.ToString(), 1); FriendsService.StoreFriend(friendID, agentID.ToString(), 1); // update the local cache m_Friends[agentID].Friends = FriendsService.GetFriends(agentID); // // Notify the friend // // Try Local if (LocalFriendshipApproved(agentID, client.Name, friendID)) { client.SendAgentOnline(new UUID[] { friendID }); return; } // The friend is not here PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); client.SendAgentOnline(new UUID[] { friendID }); } } }
private string GetUUI(UUID localUser, UUID foreignUser) { // Let's see if the user is here by any chance FriendInfo[] finfos = GetFriends(localUser); if (finfos != EMPTY_FRIENDS) // friend is here, cool { FriendInfo finfo = GetFriend(finfos, foreignUser); if (finfo != null) { return(finfo.Friend); } } else // user is not currently on this sim, need to get from the service { finfos = FriendsService.GetFriends(localUser); foreach (FriendInfo finfo in finfos) { if (finfo.Friend.StartsWith(foreignUser.ToString())) // found it! { return(finfo.Friend); } } } return(string.Empty); }
public override FriendInfo[] GetFriendsFromService(IClientAPI client) { // m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name); Boolean agentIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(client.AgentId); } if (agentIsLocal) { return(base.GetFriendsFromService(client)); } FriendInfo[] finfos = new FriendInfo[0]; // Foreigner AgentCircuitData agentClientCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); if (agentClientCircuit != null) { // Note that this is calling a different interface than base; this one calls with a string param! finfos = FriendsService.GetFriends(client.AgentId.ToString()); m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, client.AgentId.ToString()); } // m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetFriendsFromService for {0}", client.Name); return(finfos); }
public FriendInfo[] GetFriends(UUID PrincipalID) { FriendInfo[] friends = m_localService.GetFriends(PrincipalID); if (friends == null || friends.Length == 0) { friends = m_remoteService.GetFriends(PrincipalID); } return(friends); }
private void UpdateFriendsCache(UUID agentID) { lock (m_Friends) { UserFriendData friendsData; if (m_Friends.TryGetValue(agentID, out friendsData)) { friendsData.Friends = FriendsService.GetFriends(agentID); } } }
private void UpdateFriendsCache(UUID agentID) { UserFriendData friendsData = new UserFriendData(); friendsData.PrincipalID = agentID; friendsData.Refcount = 0; friendsData.Friends = FriendsService.GetFriends(agentID); lock (m_Friends) { m_Friends[agentID] = friendsData; } }
private void UpdateFriendsCache(UUID agentID) { UserFriendData friendsData = new UserFriendData { PrincipalID = agentID, Refcount = 0, Friends = FriendsService.GetFriends(agentID).ToArray() }; lock (m_Friends) { m_Friends[agentID] = friendsData; } }
public bool LocalFriendshipTerminated(UUID exfriendID) { IClientAPI friendClient = LocateClientObject(exfriendID); if (friendClient != null) { // the friend in this sim as root agent friendClient.SendTerminateFriend(exfriendID); // update local cache m_Friends[exfriendID].Friends = FriendsService.GetFriends(exfriendID); // we're done return(true); } return(false); }
public bool LocalFriendshipApproved(UUID userID, string userName, UUID friendID) { IClientAPI friendClient = LocateClientObject(friendID); if (friendClient != null) { // the prospective friend in this sim as root agent GridInstantMessage im = new GridInstantMessage(Scene, userID, userName, friendID, (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero); friendClient.SendInstantMessage(im); // update the local cache m_Friends[friendID].Friends = FriendsService.GetFriends(friendID); // we're done return(true); } return(false); }
public UserProfileViewModel( MessageHistoryService messageHistoryServ, UserSearcher userSearchingServ, FriendsService friendServ, Messanger mesServ, SessionInfo session, MessageSearcher mesSerServ, Services.PhotoService.UsersPhotoService profilePhotoService, ImageService imageServ, Authenticator authenticatorServ, ImageUrlService imageUrlServ) { Messages = new FlowDocument(); controlsVisibility = false; canExecute = true; CurrentSession = session; messageHistoryService = messageHistoryServ; userSearchingService = userSearchingServ; friendService = friendServ; this.profilePhotoService = profilePhotoService; imageService = imageServ; Friends = friendService.GetFriends(currentSession.LoggedUser.Id).ResultTask.Result; authenticatorService = authenticatorServ; imageUrlService = imageUrlServ; FindFriendEmailOrLogin = string.Empty; messengerService = mesServ; DocWidth = 248; FontSize = 13; messageSearchingService = mesSerServ; var imageUrl = profilePhotoService.GetProfilePhoto(currentSession.LoggedUser.ProfilePhotoId).Url; if (imageUrl.Contains(@"\Resources\images\ProfilePhotos")) { ImageSource = imageUrl; } else { ImageSource = imageUrlService.GetImageUrl(currentSession.LoggedUser.ProfilePhotoId); } }
private void UpdateFriendsCache(UUID agentID) { lock (m_Friends) m_Friends[agentID] = FriendsService.GetFriends(agentID); }
public JsonResult GetFriends(int userId) { var st = _friendsService.GetFriends(userId); return(Json(st, JsonRequestBehavior.AllowGet)); }
public static void Test_LINQ() { /* * * Sum() ForEach() OrderBy() OrderByDescending() Min() Max() Skip() Take() Where() * */ var liczby = new[] { 1, 2, 3, 4, 7, 2, 7, 3, 75, 34, 56, 76 }; var uzytkownicy = new[] { new { name = "Pati" }, new { name = "Arek" }, new { name = "Kuba" }, new { name = "Ajra" } }; var jakasTablicaObiektow = new[] { new { value = 1, age = 12 }, new { value = 3, age = 22 }, new { value = 3, age = 18 }, new { value = 2, age = 22 }, new { value = 1, age = 19 }, }; var posortowaneLiczby = liczby.OrderBy(liczba => liczba).ToArray(); var posortowaneObiektyPoWartowciValueRosnąco = jakasTablicaObiektow.OrderBy(x => x.value); var posortowaneObiektyPoWiekuMalejąco = jakasTablicaObiektow.OrderByDescending(x => x.age); var sumaLiczb = liczby.Sum(); var sumajakasTablicaObiektow = jakasTablicaObiektow.Sum(x => x.age); var minimalnaLiczba = liczby.Min(); var minimalnaWartosciaValue = jakasTablicaObiektow.Min(x => x.value); var najwiekszaLiczba = liczby.Max(); var najwiekszeValueZTablicyObiektow = jakasTablicaObiektow.Max(x => x.value); var średniaLiczb = liczby.Average(); var sredniaWiekowJakichObiektow = jakasTablicaObiektow.Average(x => x.age); // { 1, 2, 3, 4, 7, 2, 7, 3, 75, 34, 56, 76 }; var trzeciaICzwartaLiczba = liczby.Skip(2).Take(2).ToArray(); // 3, 4 var czyObiektyPosiadaja18latka = jakasTablicaObiektow.Any(x => x.age == 18); var czyLiczbyPosiadaja58 = liczby.Any(x => x == 56); /* * WHERE */ // Where( "element" => "warunek który zwraca true lub false, jesli zwroci true to element zostaje wrzucony do nowej listy.") // Where zwraca nową liste z elementami które spełniły warunek var duzeLiczby = liczby.Where(x => x > 50); var osiemnastolatki = jakasTablicaObiektow.Where(x => x.age == 18); var dorosliZWartociamiValue40 = jakasTablicaObiektow.Where(x => x.age >= 18 && x.value < 40); var listaZArkiem = uzytkownicy.Where(uzytkownik => uzytkownik.name == "Arek").ToList(); var arek = uzytkownicy.First(uzytkownik => uzytkownik.name == "Arek"); var liczba52 = liczby.First(x => x == 52); int kolejnaLiczba52; for (int i = 0; i < liczby.Length; i++) { if (liczby[i] == 52) { kolejnaLiczba52 = liczby[i]; break; } } // zrob z tablicy uzytkownicy, nowa tablice ze stringami, var imiona = uzytkownicy.Select(x => x.name).ToArray(); var nowiAnonimowiUzytkownicy = uzytkownicy.Select(x => new { FirstName = x.name }).ToArray(); var nowiUzytkownicy = uzytkownicy.Select(x => { var nowyuzytkownik = new NowiUzytkownicy(); nowyuzytkownik.FirstName = x.name; return(nowyuzytkownik); }).ToArray(); var nowiUzytkownicyZuzyciemKonstruktora = uzytkownicy.Select(x => new NowiUzytkownicy(x.name)).ToArray(); var user = new User("Pati", "Kubinska", "sekret"); var userDto = new UserDto(user.UserName, user.LastName); var users = new List <User>() { new User("Pati", "Kubinska", "sekret"), new User("Arek", "Chr", "sekret"), new User("Ajra", "Kubinska", "sekret") }; // List<UserDto> usersDto _mapper<User, UserDto>(users); var usersDto = users.Select(x => new UserDto(x.UserName, x.LastName)).ToList(); var usersDto2 = users.Select(x => new UserDto(x)).ToList(); var usersDto3 = new List <UserDto>(); for (int i = 0; i < users.Count; i++) { var newUserDto = new UserDto(users[i]); usersDto3.Add(newUserDto); } var userId = Guid.NewGuid(); var _friendService = new FriendsService(); // var friends = _friendService.GetFriends(userId); var _weponService = new WeponService(); _weponService.GenerateWeaponForAllPlayers(); _weponService.GenerateWeaponForPlayers(friends); // var _playerService = new PlayerService(); _playerService.PrepareAttack(30); _playerService.LogPlayers(10); _playerService.AddRandomFriends(10, Game.You); var playerStatistics = _playerService.MapPlayersToPlayerStatistic(); int index = 1; var jacysGracze = new List <Player>() { new Player("Arek"), new Player("Pati") }; _playerService.PlayersWithTheMostLivesAndFight(jacysGracze); _playerService.PlayersWithTheMostLivesAndFight(Game.Players); }
public virtual FriendInfo[] GetFriendsFromService(IClientAPI client) { return(FriendsService.GetFriends(client.AgentId)); }