Пример #1
0
        public void SendFriendOnlineStatuses(UUID user, bool isOnline)
        {
            ISyncMessagePosterService asyncPoster = m_registry.RequestModuleInterface <ISyncMessagePosterService>();

            if (asyncPoster != null)
            {
                List <FriendInfo> friends = GetFriends(user);
                foreach (FriendInfo friend in friends)
                {
                    if (friend.TheirFlags == -1 || friend.MyFlags == -1)
                    {
                        continue; //Not validiated yet!
                    }
                    UUID FriendToInform = UUID.Zero;
                    if (!UUID.TryParse(friend.Friend, out FriendToInform))
                    {
                        continue;
                    }
                    if ((friend.MyFlags & (int)FriendRights.CanSeeOnline) != (int)FriendRights.CanSeeOnline)
                    {
                        continue;//if we haven't given them the rights to see our online status, don't send the online status
                    }
                    UserInfo friendToInformUser = m_agentInfoService.GetUserInfo(friend.Friend);
                    //Now find their caps service so that we can find where they are root (and if they are logged in)
                    if (friendToInformUser != null && friendToInformUser.IsOnline)
                    {
                        //Post!
                        asyncPoster.Post(friendToInformUser.CurrentRegionURI,
                                         SyncMessageHelper.AgentStatusChange(user, FriendToInform, isOnline));
                    }
                }
            }
        }
Пример #2
0
        protected object OnGenericEvent(string FunctionName, object parameters)
        {
            if (FunctionName == "UserStatusChange")
            {
                //A user has logged in or out... we need to update friends lists across the grid

                ISyncMessagePosterService asyncPoster    = m_registry.RequestModuleInterface <ISyncMessagePosterService>();
                IFriendsService           friendsService = m_registry.RequestModuleInterface <IFriendsService>();
                if (asyncPoster != null && friendsService != null)
                {
                    //Get all friends
                    object[] info     = (object[])parameters;
                    UUID     us       = UUID.Parse(info[0].ToString());
                    bool     isOnline = bool.Parse(info[1].ToString());

                    List <FriendInfo> friends       = friendsService.GetFriends(us);
                    List <UUID>       OnlineFriends = new List <UUID>();
                    foreach (FriendInfo friend in friends)
                    {
                        if (friend.TheirFlags == -1 || friend.MyFlags == -1)
                        {
                            continue; //Not validiated yet!
                        }
                        UUID FriendToInform = UUID.Zero;
                        if (!UUID.TryParse(friend.Friend, out FriendToInform))
                        {
                            continue;
                        }

                        UserInfo user = m_agentInfoService.GetUserInfo(friend.Friend);
                        //Now find their caps service so that we can find where they are root (and if they are logged in)
                        if (user != null && user.IsOnline)
                        {
                            //Find the root agent
                            OnlineFriends.Add(FriendToInform);
                            //Post!
                            asyncPoster.Post(user.CurrentRegionURI,
                                             SyncMessageHelper.AgentStatusChange(us, FriendToInform, isOnline));
                        }
                    }
                    //If the user is coming online, send all their friends online statuses to them
                    if (isOnline)
                    {
                        UserInfo user = m_agentInfoService.GetUserInfo(us.ToString());
                        if (user != null)
                        {
                            asyncPoster.Post(user.CurrentRegionURI,
                                             SyncMessageHelper.AgentStatusChanges(OnlineFriends, us, true));
                        }
                    }
                }
            }
            return(null);
        }
Пример #3
0
        protected object OnGenericEvent(string FunctionName, object parameters)
        {
            if (FunctionName == "UserStatusChange")
            {
                //A user has logged in or out... we need to update friends lists across the grid

                IAsyncMessagePostService asyncPoster    = m_registry.RequestModuleInterface <IAsyncMessagePostService>();
                IFriendsService          friendsService = m_registry.RequestModuleInterface <IFriendsService>();
                ICapsService             capsService    = m_registry.RequestModuleInterface <ICapsService>();
                IGridService             gridService    = m_registry.RequestModuleInterface <IGridService>();
                if (asyncPoster != null && friendsService != null && capsService != null && gridService != null)
                {
                    //Get all friends
                    UserInfo     info          = (UserInfo)parameters;
                    FriendInfo[] friends       = friendsService.GetFriends(UUID.Parse(info.UserID));
                    List <UUID>  OnlineFriends = new List <UUID>();
                    UUID         us            = UUID.Parse(info.UserID);
                    foreach (FriendInfo friend in friends)
                    {
                        UUID FriendToInform = UUID.Parse(friend.Friend);
                        //Now find their caps service so that we can find where they are root (and if they are logged in)
                        IClientCapsService clientCaps = capsService.GetClientCapsService(FriendToInform);
                        if (clientCaps != null)
                        {
                            OnlineFriends.Add(FriendToInform);
                            //Find the root agent
                            IRegionClientCapsService regionClientCaps = clientCaps.GetRootCapsService();
                            if (regionClientCaps != null)
                            {
                                //Post!
                                asyncPoster.Post(regionClientCaps.RegionHandle, SyncMessageHelper.AgentStatusChange(us, FriendToInform, info.IsOnline));
                            }
                        }
                    }
                    //If they are online, send all friends online statuses to them
                    if (info.IsOnline)
                    {
                        GridRegion ourRegion = gridService.GetRegionByUUID(UUID.Zero, info.CurrentRegionID);
                        if (ourRegion != null)
                        {
                            foreach (UUID onlineFriend in OnlineFriends)
                            {
                                asyncPoster.Post(ourRegion.RegionHandle, SyncMessageHelper.AgentStatusChange(onlineFriend, us, info.IsOnline));
                            }
                        }
                    }
                }
            }
            return(null);
        }
Пример #4
0
        protected object OnGenericEvent(string FunctionName, object parameters)
        {
            if (FunctionName == "UserStatusChange")
            {
                //A user has logged in or out... we need to update friends lists across the grid

                IAsyncMessagePostService asyncPoster    = m_registry.RequestModuleInterface <IAsyncMessagePostService>();
                IFriendsService          friendsService = m_registry.RequestModuleInterface <IFriendsService>();
                ICapsService             capsService    = m_registry.RequestModuleInterface <ICapsService>();
                IGridService             gridService    = m_registry.RequestModuleInterface <IGridService>();
                if (asyncPoster != null && friendsService != null && capsService != null && gridService != null)
                {
                    //Get all friends
                    object[] info     = (object[])parameters;
                    UUID     us       = UUID.Parse(info[0].ToString());
                    bool     isOnline = bool.Parse(info[1].ToString());

                    List <FriendInfo> friends                 = friendsService.GetFriends(us);
                    List <UUID>       OnlineFriends           = new List <UUID>();
                    List <string>     previouslyContactedURLs = new List <string>();
                    foreach (FriendInfo friend in friends)
                    {
                        if (friend.TheirFlags == -1 || friend.MyFlags == -1)
                        {
                            continue; //Not validiated yet!
                        }
                        UUID   FriendToInform = UUID.Zero;
                        string url, first, last, secret;
                        if (!UUID.TryParse(friend.Friend, out FriendToInform))
                        {
                            HGUtil.ParseUniversalUserIdentifier(friend.Friend, out FriendToInform, out url, out first,
                                                                out last, out secret);
                        }
                        //Now find their caps service so that we can find where they are root (and if they are logged in)
                        IClientCapsService clientCaps = capsService.GetClientCapsService(FriendToInform);
                        if (clientCaps != null)
                        {
                            //Find the root agent
                            IRegionClientCapsService regionClientCaps = clientCaps.GetRootCapsService();
                            if (regionClientCaps != null)
                            {
                                OnlineFriends.Add(FriendToInform);
                                //Post!
                                asyncPoster.Post(regionClientCaps.RegionHandle,
                                                 SyncMessageHelper.AgentStatusChange(us, FriendToInform, isOnline));
                            }
                            else
                            {
                                //If they don't have a root agent, wtf happened?
                                capsService.RemoveCAPS(clientCaps.AgentID);
                            }
                        }
                        else
                        {
                            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>();
                            if (agentInfoService != null)
                            {
                                UserInfo friendinfo = agentInfoService.GetUserInfo(FriendToInform.ToString());
                                if (friendinfo != null && friendinfo.IsOnline)
                                {
                                    OnlineFriends.Add(FriendToInform);
                                    //Post!
                                    GridRegion r = gridService.GetRegionByUUID(UUID.Zero, friendinfo.CurrentRegionID);
                                    if (r != null)
                                    {
                                        asyncPoster.Post(r.RegionHandle,
                                                         SyncMessageHelper.AgentStatusChange(us, FriendToInform,
                                                                                             isOnline));
                                    }
                                }
                                else
                                {
                                    IUserAgentService uas = m_registry.RequestModuleInterface <IUserAgentService>();
                                    if (uas != null)
                                    {
                                        bool online = uas.RemoteStatusNotification(friend, us, isOnline);
                                        if (online)
                                        {
                                            OnlineFriends.Add(FriendToInform);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //If the user is coming online, send all their friends online statuses to them
                    if (isOnline)
                    {
                        GridRegion ourRegion = gridService.GetRegionByUUID(UUID.Zero, UUID.Parse(info[2].ToString()));
                        if (ourRegion != null)
                        {
                            foreach (UUID onlineFriend in OnlineFriends)
                            {
                                asyncPoster.Post(ourRegion.RegionHandle,
                                                 SyncMessageHelper.AgentStatusChange(onlineFriend, us, isOnline));
                            }
                        }
                    }
                }
            }
            return(null);
        }
        public List <UUID> StatusNotification(List <string> friends, UUID foreignUserID, bool online)
        {
            if (m_FriendsService == null || m_PresenceService == null)
            {
                MainConsole.Instance.WarnFormat("[USER AGENT SERVICE]: Unable to perform status notifications because friends or presence services are missing");
                return(new List <UUID> ());
            }

            List <UUID> localFriendsOnline = new List <UUID> ();

            MainConsole.Instance.DebugFormat("[USER AGENT SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends", foreignUserID, friends.Count);

            // First, let's double check that the reported friends are, indeed, friends of that user
            // And let's check that the secret matches
            List <string> usersToBeNotified = new List <string> ();

            foreach (string uui in friends)
            {
                UUID   localUserID;
                string secret = string.Empty, tmp = string.Empty;
                if (HGUtil.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret))
                {
                    List <FriendInfo> friendInfos = m_FriendsService.GetFriends(localUserID);
                    foreach (FriendInfo finfo in friendInfos)
                    {
                        if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret))
                        {
                            // great!
                            usersToBeNotified.Add(localUserID.ToString());
                        }
                    }
                }
            }

            // Now, let's send the notifications
            MainConsole.Instance.DebugFormat("[USER AGENT SERVICE]: Status notification: user has {0} local friends", usersToBeNotified.Count);

            // First, let's send notifications to local users who are online in the home grid

            //Send "" because if we pass the UUID, it will get the locations for all friends, even on the grid they came from
            List <UserInfo> friendSessions = m_PresenceService.GetUserInfos(usersToBeNotified);

            foreach (UserInfo friend in friendSessions)
            {
                if (friend.IsOnline)
                {
                    GridRegion ourRegion = m_GridService.GetRegionByUUID(null, friend.CurrentRegionID);
                    if (ourRegion != null)
                    {
                        m_asyncPostService.Post(ourRegion.RegionHandle,
                                                SyncMessageHelper.AgentStatusChange(foreignUserID, UUID.Parse(friend.UserID), true));
                    }
                }
            }

            // Lastly, let's notify the rest who may be online somewhere else
            foreach (string user in usersToBeNotified)
            {
                UUID id = new UUID(user);
                if (m_TravelingAgents.ContainsKey(id) && m_TravelingAgents[id].GridExternalName != m_GridName)
                {
                    string url = m_TravelingAgents[id].GridExternalName;
                    // forward
                    MainConsole.Instance.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
                }
            }

            // and finally, let's send the online friends
            if (online)
            {
                return(localFriendsOnline);
            }
            else
            {
                return(new List <UUID> ());
            }
        }