Exemple #1
0
        private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
        {
            FriendInfo[] friends = GetFriends(remoteClient.AgentId);
            if (friends.Length == 0)
            {
                return;
            }

            MainConsole.Instance.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights,
                                             target);
            // Let's find the friend in this user's friend list
            FriendInfo friend = null;

#if (!ISWIN)
            foreach (FriendInfo fi in friends)
            {
                if (fi.Friend == target.ToString())
                {
                    friend = fi;
                }
            }
#else
            foreach (FriendInfo fi in friends.Where(fi => fi.Friend == target.ToString()))
            {
                friend = fi;
            }
#endif

            if (friend != null) // Found it
            {
                // Store it on the DB
                FriendsService.StoreFriend(requester, target.ToString(), rights);

                // Store it in the local cache
                int myFlags = friend.MyFlags;
                friend.MyFlags = rights;

                // Always send this back to the original client
                remoteClient.SendChangeUserRights(requester, target, rights);

                //
                // Notify the friend
                //


                // Try local
                if (!LocalGrantRights(requester, target, myFlags, rights))
                {
                    SyncMessagePosterService.Post(SyncMessageHelper.FriendGrantRights(
                                                      requester, target, myFlags, rights, m_Scenes[0].RegionInfo.RegionHandle),
                                                  m_Scenes[0].RegionInfo.RegionHandle);
                }
            }
        }
Exemple #2
0
        private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
        {
            FriendInfo[] friends = GetFriends(remoteClient.AgentId);
            if (friends.Length == 0)
            {
                return;
            }

            m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target);
            // Let's find the friend in this user's friend list
            FriendInfo friend = null;

            foreach (FriendInfo fi in friends)
            {
                if (fi.Friend == target.ToString())
                {
                    friend = fi;
                }
            }

            if (friend != null) // Found it
            {
                // Store it on the DB
                FriendsService.StoreFriend(requester, target.ToString(), rights);

                // Store it in the local cache
                int myFlags = friend.MyFlags;
                friend.MyFlags = rights;

                // Always send this back to the original client
                remoteClient.SendChangeUserRights(requester, target, rights);

                //
                // Notify the friend
                //


                // Try local
                if (!LocalGrantRights(requester, target, myFlags, rights))
                {
                    UserInfo friendSession = m_Scenes[0].RequestModuleInterface <IAgentInfoService>().GetUserInfo(target.ToString());
                    if (friendSession != null && friendSession.IsOnline)
                    {
                        GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID,
                                                                        friendSession.CurrentRegionID);
                        AsyncMessagePostService.Post(region.RegionHandle, SyncMessageHelper.FriendGrantRights(
                                                         requester, target, myFlags, rights, region.RegionHandle));
                    }
                }
            }
        }