Esempio n. 1
0
        private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID)
        {
            FriendsService.Delete(agentID, exfriendID.ToString());
            FriendsService.Delete(exfriendID, agentID.ToString());

            // Update local cache
            UpdateFriendsCache(agentID);

            client.SendTerminateFriend(exfriendID);

            //
            // Notify the friend
            //

            // Try local
            if (LocalFriendshipTerminated(exfriendID, agentID))
            {
                return;
            }

            UserInfo friendSession = m_Scenes[0].RequestModuleInterface <IAgentInfoService>().GetUserInfo(exfriendID.ToString());

            if (friendSession != null && friendSession.IsOnline)
            {
                GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.CurrentRegionID);
                AsyncMessagePostService.Post(region.RegionHandle, SyncMessageHelper.FriendTerminated(
                                                 agentID, exfriendID, region.RegionHandle));
            }
        }
Esempio n. 2
0
        private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List <UUID> callingCardFolders)
        {
            m_log.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", agentID, friendID);

            FriendsService.Delete(agentID, friendID.ToString());
            FriendsService.Delete(friendID, agentID.ToString());

            //
            // Notify the friend
            //

            // Try local
            if (LocalFriendshipDenied(agentID, client.Name, friendID))
            {
                return;
            }

            UserInfo friendSession = m_Scenes[0].RequestModuleInterface <IAgentInfoService>().GetUserInfo(friendID.ToString());

            if (friendSession != null && friendSession.IsOnline)
            {
                GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.CurrentRegionID);
                AsyncMessagePostService.Post(region.RegionHandle, SyncMessageHelper.FriendshipDenied(
                                                 agentID, client.Name, friendID, region.RegionHandle));
            }
        }
Esempio n. 3
0
        private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID,
                                            List <UUID> callingCardFolders)
        {
            MainConsole.Instance.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
            UpdateFriendsCache(agentID);

            // Notify the friend and send calling card to the local user

            ICallingCardModule ccmodule = client.Scene.RequestModuleInterface <ICallingCardModule>();

            if (ccmodule != null)
            {
                UserAccount account  = client.Scene.UserAccountService.GetUserAccount(client.AllScopeIDs, friendID);
                UUID        folderID =
                    client.Scene.InventoryService.GetFolderForType(agentID, InventoryType.Unknown, AssetType.CallingCard)
                    .ID;
                if (account != null)
                {
                    ccmodule.CreateCallingCard(client, friendID, folderID, account.Name);
                }
            }

            // Try Local
            if (LocalFriendshipApproved(agentID, client.Name, client, friendID))
            {
                return;
            }
            SyncMessagePosterService.PostToServer(SyncMessageHelper.FriendshipApproved(
                                                      agentID, client.Name, friendID, m_scene.RegionInfo.RegionID));
        }
Esempio n. 4
0
        private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List <UUID> callingCardFolders)
        {
            MainConsole.Instance.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", agentID, friendID);


            FriendInfo[] friends = FriendsService.GetFriendsRequest(agentID).ToArray();
            foreach (FriendInfo fi in friends)
            {
                if (fi.MyFlags == 0)
                {
                    UUID fromAgentID;
                    if (!UUID.TryParse(fi.Friend, out fromAgentID))
                    {
                        continue;
                    }
                    if (fromAgentID == friendID) //Get those pesky HG travelers as well
                    {
                        FriendsService.Delete(agentID, fi.Friend);
                    }
                }
            }
            FriendsService.Delete(friendID, agentID.ToString());

            //
            // Notify the friend
            //

            // Try local
            if (LocalFriendshipDenied(agentID, client.Name, friendID))
            {
                return;
            }
            SyncMessagePosterService.PostToServer(SyncMessageHelper.FriendshipDenied(
                                                      agentID, client.Name, friendID, m_scene.RegionInfo.RegionID));
        }
Esempio n. 5
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));
                    }
                }
            }
        }
Esempio n. 6
0
 /// <summary>
 ///     Server side
 /// </summary>
 /// <param name="FunctionName"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 protected object OnGenericEvent(string FunctionName, object parameters)
 {
     if (FunctionName == "EstateUpdated")
     {
         EstateSettings            es = (EstateSettings)parameters;
         IEstateConnector          estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();
         ISyncMessagePosterService asyncPoster     =
             m_registry.RequestModuleInterface <ISyncMessagePosterService>();
         IGridService gridService = m_registry.RequestModuleInterface <IGridService>();
         if (estateConnector != null)
         {
             List <UUID> regions = estateConnector.GetRegions((int)es.EstateID);
             if (regions != null)
             {
                 foreach (UUID region in regions)
                 {
                     //Send the message to update all regions that are in this estate, as a setting changed
                     if (gridService != null && asyncPoster != null)
                     {
                         GridRegion r = gridService.GetRegionByUUID(null, region);
                         if (r != null)
                         {
                             asyncPoster.Post(r.ServerURI,
                                              SyncMessageHelper.UpdateEstateInfo(es.EstateID, region));
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
Esempio n. 7
0
        public virtual void InternalCross(IScenePresence agent, Vector3 attemptedPos, bool isFlying,
                                          GridRegion crossingRegion)
        {
            MainConsole.Instance.DebugFormat("[Entity transfer]: Crossing agent {0} to region {1}",
                                             agent.Name, crossingRegion.RegionName);

            try {
                agent.SetAgentLeaving(crossingRegion);

                AgentData cAgent = new AgentData();
                agent.CopyTo(cAgent);
                cAgent.Position = attemptedPos;
                if (isFlying)
                {
                    cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
                }

                AgentCircuitData agentCircuit = BuildCircuitDataForPresence(agent, attemptedPos);
                agentCircuit.TeleportFlags = (uint)TeleportFlags.ViaRegionID;

                //This does UpdateAgent and closing of child agents
                //  messages if they need to be called
                ISyncMessagePosterService syncPoster =
                    agent.Scene.RequestModuleInterface <ISyncMessagePosterService> ();
                if (syncPoster != null)
                {
                    syncPoster.PostToServer(SyncMessageHelper.CrossAgent(crossingRegion, attemptedPos,
                                                                         agent.Velocity, agentCircuit, cAgent,
                                                                         agent.Scene.RegionInfo.RegionID));
                }
            } catch (Exception ex) {
                MainConsole.Instance.Warn("[Entity transfer]: Exception in crossing: " + ex);
            }
        }
Esempio n. 8
0
        private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im)
        {
            // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID)
            // We stick this agent's ID as imSession, so that it's directly available on the receiving end
            im.imSessionID = im.fromAgentID;

            // Try the local sim
            UserAccount account = UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, agentID);

            im.fromAgentName = (account == null) ? "Unknown" : account.FirstName + " " + account.LastName;

            if (LocalFriendshipOffered(friendID, im))
            {
                return;
            }

            // The prospective friend is not here [as root]. Let's forward.
            UserInfo friendSession = m_Scenes[0].RequestModuleInterface <IAgentInfoService>().GetUserInfo(friendID.ToString());

            if (friendSession != null && friendSession.IsOnline)
            {
                GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.CurrentRegionID);
                AsyncMessagePostService.Post(region.RegionHandle, SyncMessageHelper.FriendshipOffered(
                                                 agentID, friendID, im, region.RegionHandle));
            }
            // If the prospective friend is not online, he'll get the message upon login.
        }
        public void CancelTeleport(UUID agentID, UUID regionID)
        {
            ISyncMessagePosterService syncPoster = m_scene.RequestModuleInterface <ISyncMessagePosterService> ();

            if (syncPoster != null)
            {
                syncPoster.PostToServer(SyncMessageHelper.CancelTeleport(agentID, regionID));
            }
        }
Esempio n. 10
0
        public void CancelTeleport(UUID AgentID, ulong RegionHandle)
        {
            ISyncMessagePosterService syncPoster = m_scenes[0].RequestModuleInterface <ISyncMessagePosterService>();

            if (syncPoster != null)
            {
                syncPoster.Post(SyncMessageHelper.CancelTeleport(AgentID, RegionHandle), RegionHandle);
            }
        }
Esempio n. 11
0
        void EventManager_OnStartupFullyComplete(IScene scene, List <string> data)
        {
            //Just send the RegionIsOnline message, it will log out all the agents for the region as well
            ISyncMessagePosterService syncMessage = scene.RequestModuleInterface <ISyncMessagePosterService> ();

            if (syncMessage != null)
            {
                syncMessage.PostToServer(SyncMessageHelper.RegionIsOnline(scene.RegionInfo.RegionID));
            }
        }
Esempio n. 12
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);
                }
            }
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
        public void RemoveRegion(Scene scene)
        {
            ISyncMessagePosterService syncMessage = scene.RequestModuleInterface <ISyncMessagePosterService>();

            if (syncMessage != null)
            {
                syncMessage.Post(SyncMessageHelper.LogoutRegionAgents(scene.RegionInfo.RegionHandle), scene.RegionInfo.RegionHandle);
            }
            scene.EventManager.OnNewClient     -= OnNewClient;
            scene.EventManager.OnClosingClient -= OnClosingClient;
            m_scenes.Remove(scene);
        }
Esempio n. 15
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));
                    }
                }
            }
        }
Esempio n. 16
0
 public void RemoveRegion(IScene scene)
 {
     if (!scene.CloseQuietly)
     {
         ISyncMessagePosterService syncMessage = scene.RequestModuleInterface <ISyncMessagePosterService> ();
         if (syncMessage != null)
         {
             syncMessage.PostToServer(SyncMessageHelper.LogoutRegionAgents(scene.RegionInfo.RegionID));
         }
     }
     scene.EventManager.OnNewClient     -= OnNewClient;
     scene.EventManager.OnClosingClient -= OnClosingClient;
     m_scene = null;
 }
Esempio n. 17
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);
        }
        public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt,
                                       uint teleportFlags)
        {
            sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
            if (finalDestination == null)
            {
                sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
                return;
            }

            MainConsole.Instance.DebugFormat("[Entity transfer]: Request Teleport to {0}:{1}/{2}",
                                             finalDestination.ServerURI, finalDestination.RegionName, position);

            sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");
            sp.SetAgentLeaving(finalDestination);

            // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
            // both regions
            if (sp.ParentID != UUID.Zero)
            {
                sp.StandUp();
            }

            AgentCircuitData agentCircuit = BuildCircuitDataForPresence(sp, position);

            AgentData agent = new AgentData();

            sp.CopyTo(agent);
            // Fix the position
            agent.Position = position;

            ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface <ISyncMessagePosterService> ();

            if (syncPoster != null)
            {
                // This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
                //  messages if they need to be called and deals with the callback
                syncPoster.PostToServer(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance,
                                                                        agentCircuit,
                                                                        agent,
                                                                        teleportFlags,
                                                                        finalDestination,
                                                                        sp.Scene.RegionInfo.RegionID));
            }
        }
Esempio n. 19
0
        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
            UpdateFriendsCache(agentID);

            //
            // Notify the friend
            //

            //
            // Send calling card to the local user
            //

            ICallingCardModule ccmodule = client.Scene.RequestModuleInterface <ICallingCardModule>();

            if (ccmodule != null)
            {
                UserAccount account  = ((Scene)client.Scene).UserAccountService.GetUserAccount(UUID.Zero, friendID);
                UUID        folderID = ((Scene)client.Scene).InventoryService.GetFolderForType(agentID, AssetType.CallingCard).ID;
                ccmodule.CreateCallingCard(client, friendID, folderID, account.Name);
            }

            // Try Local
            if (LocalFriendshipApproved(agentID, client.Name, client, friendID))
            {
                return;
            }

            // The friend is not here
            UserInfo friendSession = m_Scenes[0].RequestModuleInterface <IAgentInfoService>().GetUserInfo(friendID.ToString());

            if (friendSession != null && friendSession.IsOnline)
            {
                GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.CurrentRegionID);
                AsyncMessagePostService.Post(region.RegionHandle, SyncMessageHelper.FriendshipApproved(
                                                 agentID, client.Name, friendID, region.RegionHandle));
            }
        }
Esempio n. 20
0
        private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List <UUID> callingCardFolders)
        {
            MainConsole.Instance.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", agentID, friendID);

            FriendsService.Delete(agentID, friendID.ToString());
            FriendsService.Delete(friendID, agentID.ToString());

            //
            // Notify the friend
            //

            // Try local
            if (LocalFriendshipDenied(agentID, client.Name, friendID))
            {
                return;
            }
            SyncMessagePosterService.Post(SyncMessageHelper.FriendshipDenied(
                                              agentID, client.Name, friendID, m_Scenes[0].RegionInfo.RegionHandle),
                                          m_Scenes[0].RegionInfo.RegionHandle);
        }
Esempio n. 21
0
        private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im)
        {
            // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID)
            // We stick this agent's ID as imSession, so that it's directly available on the receiving end
            im.SessionID = im.FromAgentID;

            // Try the local sim
            UserAccount account = UserAccountService.GetUserAccount(m_scene.RegionInfo.AllScopeIDs, agentID);

            im.FromAgentName = (account == null) ? "Unknown" : account.Name;

            if (LocalFriendshipOffered(friendID, im))
            {
                return;
            }

            // The prospective friend is not here [as root]. Let's4 forward.
            SyncMessagePosterService.PostToServer(SyncMessageHelper.FriendshipOffered(agentID, friendID, im,
                                                                                      m_scene.RegionInfo.RegionID));
            // If the prospective friend is not online, he'll get the message upon login.
        }
Esempio n. 22
0
        /// <summary>
        /// Tell a single agent to disconnect from the region.
        /// </summary>
        /// <param name="regionHandle"></param>
        /// <param name="agentID"></param>
        public bool IncomingCloseAgent(IScene scene, UUID agentID)
        {
            //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);

            IScenePresence presence = scene.GetScenePresence(agentID);

            if (presence != null)
            {
                bool RetVal = scene.RemoveAgent(presence);

                ISyncMessagePosterService syncPoster = scene.RequestModuleInterface <ISyncMessagePosterService> ();
                if (syncPoster != null)
                {
                    //Tell the grid that we are logged out
                    syncPoster.Post(SyncMessageHelper.DisableSimulator(presence.UUID, scene.RegionInfo.RegionHandle), scene.RegionInfo.RegionHandle);
                }

                return(RetVal);
            }
            return(false);
        }
Esempio n. 23
0
        private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID)
        {
            FriendsService.Delete(agentID, exfriendID.ToString());
            FriendsService.Delete(exfriendID, agentID.ToString());

            // Update local cache
            UpdateFriendsCache(agentID);

            client.SendTerminateFriend(exfriendID);

            // Notify the friend

            // Try local
            if (LocalFriendshipTerminated(exfriendID, agentID))
            {
                return;
            }

            SyncMessagePosterService.PostToServer(SyncMessageHelper.FriendTerminated(
                                                      agentID, exfriendID, m_scene.RegionInfo.RegionID));
        }
Esempio n. 24
0
        private void FixNeighbors(GridRegion regionInfos, List <GridRegion> neighbors, bool down)
        {
            IAsyncMessagePostService postService = m_registryCore.RequestModuleInterface <IAsyncMessagePostService>();

            foreach (GridRegion r in neighbors)
            {
                if (m_KnownNeighbors.ContainsKey(r.RegionID))
                {
                    //Add/Remove them to/from the list
                    if (down)
                    {
                        m_KnownNeighbors[r.RegionID].Remove(regionInfos);
                    }
                    else if (m_KnownNeighbors[r.RegionID].Find(delegate(GridRegion rr)
                    {
                        if (rr.RegionID == regionInfos.RegionID)
                        {
                            return(true);
                        }
                        return(false);
                    }) == null)
                    {
                        m_KnownNeighbors[r.RegionID].Add(regionInfos);
                    }
                }

                if (postService != null)
                {
                    postService.Post(r.RegionHandle,
                                     SyncMessageHelper.NeighborChange(r.RegionID, regionInfos.RegionID, down));
                }
            }

            if (down)
            {
                m_KnownNeighbors.Remove(regionInfos.RegionID);
            }
        }
Esempio n. 25
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);
        }
Esempio n. 26
0
        public void OnConnectionClose(IClientAPI client)
        {
            IScenePresence sp = null;

            client.Scene.TryGetScenePresence(client.AgentId, out sp);
            if (client.IsLoggingOut && sp != null & !sp.IsChildAgent)
            {
                MainConsole.Instance.InfoFormat("[ActivityDetector]: Detected logout of user {0} in region {1}", client.Name,
                                                client.Scene.RegionInfo.RegionName);

                //Inform the grid service about it

                if (m_zombieAgents.Contains(client.AgentId))
                {
                    m_zombieAgents.Remove(client.AgentId);
                    return; //They are a known zombie, just clear them out and go on with life!
                }
                AgentPosition agentpos = new AgentPosition
                {
                    AgentID  = sp.UUID,
                    AtAxis   = sp.CameraAtAxis,
                    Center   = sp.CameraPosition,
                    Far      = sp.DrawDistance,
                    LeftAxis = Vector3.Zero,
                    Position = sp.AbsolutePosition
                };
                if (agentpos.Position.X > sp.Scene.RegionInfo.RegionSizeX)
                {
                    agentpos.Position.X = sp.Scene.RegionInfo.RegionSizeX;
                }
                if (agentpos.Position.Y > sp.Scene.RegionInfo.RegionSizeY)
                {
                    agentpos.Position.Y = sp.Scene.RegionInfo.RegionSizeY;
                }
                if (agentpos.Position.Z > sp.Scene.RegionInfo.RegionSizeZ)
                {
                    agentpos.Position.Z = sp.Scene.RegionInfo.RegionSizeZ;
                }
                if (agentpos.Position.X < 0)
                {
                    agentpos.Position.X = 0;
                }
                if (agentpos.Position.Y < 0)
                {
                    agentpos.Position.Y = 0;
                }
                if (agentpos.Position.Z < 0)
                {
                    agentpos.Position.Z = 0;
                }
                agentpos.RegionHandle     = sp.Scene.RegionInfo.RegionHandle;
                agentpos.Size             = sp.PhysicsActor != null ? sp.PhysicsActor.Size : new Vector3(0, 0, 1.8f);
                agentpos.UpAxis           = Vector3.Zero;
                agentpos.Velocity         = sp.Velocity;
                agentpos.UserGoingOffline = true; //Don't attempt to add us into other regions

                //Send the child agent data update
                ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface <ISyncMessagePosterService>();
                if (syncPoster != null)
                {
                    syncPoster.Post(SyncMessageHelper.SendChildAgentUpdate(agentpos, sp.Scene.RegionInfo.RegionHandle),
                                    sp.Scene.RegionInfo.RegionHandle);
                }
                client.Scene.RequestModuleInterface <ISyncMessagePosterService>().Get(
                    SyncMessageHelper.AgentLoggedOut(client.AgentId, client.Scene.RegionInfo.RegionHandle),
                    client.AgentId, client.Scene.RegionInfo.RegionHandle);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// This Closes child agents on neighboring regions
        /// Calls an asynchronous method to do so..  so it doesn't lag the sim.
        /// </summary>
        protected IScenePresence CrossAgentToNewRegionAsync(IScenePresence agent, Vector3 pos,
                                                            GridRegion crossingRegion, bool isFlying)
        {
            m_log.DebugFormat("[EntityTransferModule]: Crossing agent {0} to region {1}", agent.Name, crossingRegion.RegionName);

            IScene m_scene = agent.Scene;

            if (crossingRegion != null)
            {
                //Make sure that all attachments are ready for the teleport
                IAttachmentsModule attModule = agent.Scene.RequestModuleInterface <IAttachmentsModule>();
                if (attModule != null)
                {
                    attModule.ValidateAttachments(agent.UUID);
                }

                int xOffset = crossingRegion.RegionLocX - m_scene.RegionInfo.RegionLocX;
                int yOffset = crossingRegion.RegionLocY - m_scene.RegionInfo.RegionLocY;

                if (xOffset < 0)
                {
                    pos.X += m_scene.RegionInfo.RegionSizeX;
                }
                else if (xOffset > 0)
                {
                    pos.X -= m_scene.RegionInfo.RegionSizeX;
                }

                if (yOffset < 0)
                {
                    pos.Y += m_scene.RegionInfo.RegionSizeY;
                }
                else if (yOffset > 0)
                {
                    pos.Y -= m_scene.RegionInfo.RegionSizeY;
                }

                //Make sure that they are within bounds (velocity can push it out of bounds)
                if (pos.X < 0)
                {
                    pos.X = 1;
                }
                if (pos.Y < 0)
                {
                    pos.Y = 1;
                }

                if (pos.X > crossingRegion.RegionSizeX)
                {
                    pos.X = crossingRegion.RegionSizeX - 1;
                }
                if (pos.Y > crossingRegion.RegionSizeY)
                {
                    pos.Y = crossingRegion.RegionSizeY - 1;
                }

                AgentData cAgent = new AgentData();
                agent.CopyTo(cAgent);
                cAgent.Position = pos;
                if (isFlying)
                {
                    cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
                }

                AgentCircuitData agentCircuit = agent.ControllingClient.RequestClientInfo();
                agentCircuit.startpos = pos;
                agentCircuit.child    = false;
                IAvatarAppearanceModule appearance = agent.RequestModuleInterface <IAvatarAppearanceModule> ();
                if (appearance != null)
                {
                    agentCircuit.Appearance = appearance.Appearance;
                }

                IEventQueueService eq = agent.Scene.RequestModuleInterface <IEventQueueService>();
                if (eq != null)
                {
                    //This does UpdateAgent and closing of child agents
                    //  messages if they need to be called
                    ISyncMessagePosterService syncPoster = agent.Scene.RequestModuleInterface <ISyncMessagePosterService>();
                    if (syncPoster != null)
                    {
                        OSDMap map = syncPoster.Get(SyncMessageHelper.CrossAgent(crossingRegion, pos,
                                                                                 agent.Velocity, agentCircuit, cAgent, agent.Scene.RegionInfo.RegionHandle),
                                                    agent.Scene.RegionInfo.RegionHandle);
                        bool result = map["Success"].AsBoolean();
                        if (!result)
                        {
                            agent.ControllingClient.SendTeleportFailed(map["Reason"].AsString());
                            return(agent);
                        }
                    }
                }

                agent.MakeChildAgent();

                //Revolution- We already were in this region... we don't need updates about the avatars we already know about, right?
                // OLD: now we have a child agent in this region. Request and send all interesting data about (root) agents in the sim
                //agent.SendOtherAgentsAvatarDataToMe();
                //agent.SendOtherAgentsAppearanceToMe();

                //Kill the groups here, otherwise they will become ghost attachments
                //  and stay in the sim, they'll get readded below into the new sim
                KillAttachments(agent);
            }
            return(agent);
        }
Esempio n. 28
0
        public void OnConnectionClose(IClientAPI client)
        {
            IScenePresence sp = null;

            client.Scene.TryGetScenePresence(client.AgentId, out sp);
            if (client.IsLoggingOut && sp != null & !sp.IsChildAgent)
            {
                m_log.InfoFormat("[ActivityDetector]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);

                //Inform the grid service about it

                if (m_zombieAgents.Contains(client.AgentId))
                {
                    m_zombieAgents.Remove(client.AgentId);
                    return; //They are a known zombie, just clear them out and go on with life!
                }
                client.Scene.RequestModuleInterface <ISyncMessagePosterService>().Get(SyncMessageHelper.AgentLoggedOut(client.AgentId, client.Scene.RegionInfo.RegionHandle), client.Scene.RegionInfo.RegionHandle);
            }
        }
        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> ());
            }
        }
Esempio n. 30
0
        public void OnConnectionClose(IClientAPI client)
        {
            IScenePresence sp = null;

            client.Scene.TryGetScenePresence(client.AgentId, out sp);
            if (client.IsLoggingOut && sp != null & !sp.IsChildAgent)
            {
                m_log.InfoFormat("[ActivityDetector]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);

                //Inform the grid service about it

                client.Scene.RequestModuleInterface <ISyncMessagePosterService>().Get(SyncMessageHelper.AgentLoggedOut(client.AgentId, client.Scene.RegionInfo.RegionHandle), client.Scene.RegionInfo.RegionHandle);
            }
        }