public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
        {
            position = new Vector3(128, 128, 0);
            lookAt   = Vector3.UnitY;

            MainConsole.Instance.DebugFormat("[USER AGENT SERVICE]: Request to get home region of user {0}", userID);

            GridRegion home  = null;
            UserInfo   uinfo = m_PresenceService.GetUserInfo(userID.ToString());

            if (uinfo != null)
            {
                if (uinfo.HomeRegionID != UUID.Zero)
                {
                    home     = m_GridService.GetRegionByUUID(null, uinfo.HomeRegionID);
                    position = uinfo.HomePosition;
                    lookAt   = uinfo.HomeLookAt;
                }
                if (home == null || ((home.Flags & (int)Aurora.Framework.RegionFlags.Safe)
                                     != (int)Aurora.Framework.RegionFlags.Safe))
                {
                    home = m_GatekeeperService.GetHyperlinkRegion(UUID.Zero);
                    if (home != null)
                    {
                        position = new Vector3(home.RegionSizeX / 2, home.RegionSizeY / 2, 20);
                        lookAt   = Vector3.Zero;
                    }
                }
            }

            return(home);
        }
示例#2
0
        public GridRegion GetHyperlinkRegion(UUID regionID)
        {
            MainConsole.Instance.DebugFormat("[GATEKEEPER SERVICE]: Request to get hyperlink region {0}", regionID);

            if (!m_AllowTeleportsToAnyRegion)
            {
                if (!m_foundDefaultRegion || m_DefaultGatewayRegion == null)
                {
                    m_DefaultGatewayRegion = FindDefaultRegion();
                }
                // Don't even check the given regionID
                return(m_DefaultGatewayRegion);
            }

            GridRegion region = m_GridService.GetRegionByUUID(null, regionID);

            if (region != null && (region.Flags & (int)Aurora.Framework.RegionFlags.Safe) == (int)Aurora.Framework.RegionFlags.Safe)
            {
                return(region);
            }
            if (!m_foundDefaultRegion || m_DefaultGatewayRegion == null)
            {
                m_DefaultGatewayRegion = FindDefaultRegion();
            }
            if (m_DefaultGatewayRegion != null && (m_DefaultGatewayRegion.Flags & (int)Aurora.Framework.RegionFlags.Safe) == (int)Aurora.Framework.RegionFlags.Safe)
            {
                return(m_DefaultGatewayRegion);
            }
            return(m_DefaultGatewayRegion = FindDefaultRegion());
        }
示例#3
0
        public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
        {
            position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY;

            m_log.DebugFormat("[USER AGENT SERVICE]: Request to get home region of user {0}", userID);

            GridRegion   home  = null;
            GridUserInfo uinfo = m_GridUserService.GetGridUserInfo(userID.ToString());

            if (uinfo != null)
            {
                if (uinfo.HomeRegionID != UUID.Zero)
                {
                    home     = m_GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
                    position = uinfo.HomePosition;
                    lookAt   = uinfo.HomeLookAt;
                }
                if (home == null)
                {
                    List <GridRegion> defs = m_GridService.GetDefaultRegions(UUID.Zero);
                    if (defs != null && defs.Count > 0)
                    {
                        home = defs[0];
                    }
                }
            }

            return(home);
        }
示例#4
0
        public GridRegion GetHyperlinkRegion(UUID regionID)
        {
            m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get hyperlink region {0}", regionID);

            if (!m_AllowTeleportsToAnyRegion)
            {
                // Don't even check the given regionID
                return(m_DefaultGatewayRegion);
            }

            GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID);

            return(region);
        }
        private bool ForwardToSim(string op, UUID fromID, string name, String fromUUI, UUID toID, string message)
        {
            PresenceInfo session = null;
            GridRegion   region  = null;

            PresenceInfo[] sessions = m_PresenceService.GetAgents(new string[] { toID.ToString() });
            if (sessions != null && sessions.Length > 0)
            {
                session = sessions[0];
            }
            if (session != null)
            {
                region = m_GridService.GetRegionByUUID(UUID.Zero, session.RegionID);
            }

            switch (op)
            {
            case "FriendshipOffered":
                // Let's store backwards
                string secret = UUID.Random().ToString().Substring(0, 8);
                m_FriendsService.StoreFriend(toID.ToString(), fromUUI + ";" + secret, 0);
                if (m_FriendsLocalSimConnector != null)     // standalone
                {
                    GridInstantMessage im = new GridInstantMessage(null, fromID, name, toID,
                                                                   (byte)InstantMessageDialog.FriendshipOffered, message, false, Vector3.Zero);
                    // !! HACK
                    im.imSessionID = im.fromAgentID;
                    return(m_FriendsLocalSimConnector.LocalFriendshipOffered(toID, im));
                }
                else if (region != null)     // grid
                {
                    return(m_FriendsSimConnector.FriendshipOffered(region, fromID, toID, message, name));
                }
                break;

            case "ApproveFriendshipRequest":
                if (m_FriendsLocalSimConnector != null)     // standalone
                {
                    return(m_FriendsLocalSimConnector.LocalFriendshipApproved(fromID, name, toID));
                }
                else if (region != null)     //grid
                {
                    return(m_FriendsSimConnector.FriendshipApproved(region, fromID, name, toID));
                }
                break;
            }

            return(false);
        }
示例#6
0
        /// <summary>
        /// Gets user information for change user info page on site
        /// </summary>
        /// <param name="map">UUID</param>
        /// <returns>Verified, HomeName, HomeUUID, Online, Email, FirstName, LastName</returns>
        byte[] GetGridUserInfo(OSDMap map)
        {
            string uuid = String.Empty;

            uuid = map["UUID"].AsString();

            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService>();
            UserAccount         user           = accountService.GetUserAccount(UUID.Zero, map["UUID"].AsUUID());
            IAgentInfoService   agentService   = m_registry.RequestModuleInterface <IAgentInfoService>();

            UserInfo userinfo;
            OSDMap   resp = new OSDMap();

            bool verified = user != null;

            resp["Verified"] = OSD.FromBoolean(verified);
            if (verified)
            {
                userinfo = agentService.GetUserInfo(uuid);
                IGridService gs = m_registry.RequestModuleInterface <IGridService>();
                Services.Interfaces.GridRegion gr = gs.GetRegionByUUID(UUID.Zero, userinfo.HomeRegionID);

                resp["HomeUUID"] = OSD.FromUUID(userinfo.HomeRegionID);
                resp["HomeName"] = OSD.FromString(gr.RegionName);
                resp["Online"]   = OSD.FromBoolean(userinfo.IsOnline);
                resp["Email"]    = OSD.FromString(user.Email);
                resp["Name"]     = OSD.FromString(user.Name);
            }

            string       xmlString = OSDParser.SerializeJsonString(resp);
            UTF8Encoding encoding  = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
示例#7
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);
 }
示例#8
0
        private byte[] Deregister(Dictionary <string, object> request)
        {
            UUID regionID = UUID.Zero;

            if (request.ContainsKey("REGIONID"))
            {
                UUID.TryParse(request["REGIONID"].ToString(), out regionID);
            }
            else
            {
                MainConsole.Instance.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region");
            }

            UUID sessionID = UUID.Zero;

            if (request.ContainsKey("SESSIONID"))
            {
                UUID.TryParse(request["SESSIONID"].ToString(), out sessionID);
            }
            else
            {
                MainConsole.Instance.WarnFormat("[GRID HANDLER]: no sessionID in request to deregister region");
            }
            GridRegion r = m_GridService.GetRegionByUUID(UUID.Zero, regionID);

            if (r != null & m_SessionID == r.RegionHandle.ToString())
            {
                bool result = m_GridService.DeregisterRegion(r.RegionHandle, regionID, sessionID);
                if (result)
                {
                    m_registry.RequestModuleInterface <IGridRegistrationService>().RemoveUrlsForClient(
                        sessionID.ToString());
                }
                if (result)
                {
                    return(SuccessResult());
                }
                else
                {
                    return(FailureResult());
                }
            }
            return(FailureResult());
        }
示例#9
0
        private void SendToEstate(uint EstateID, Dictionary <string, object> sendData)
        {
            List <UUID> regions = m_EstateModule.Scenes[0].GetEstateRegions((int)EstateID);

            // Don't send to the same instance twice
            List <string> done = new List <string>();

            // Handle local regions locally
            lock (m_EstateModule.Scenes)
            {
                foreach (Scene s in m_EstateModule.Scenes)
                {
                    RegionInfo sreg = s.RegionInfo;
                    if (regions.Contains(sreg.RegionID))
                    {
                        string url = sreg.ExternalHostName + ":" + sreg.HttpPort;
                        regions.Remove(sreg.RegionID);
                        if (!done.Contains(url)) // we may have older regs with same url lost in dbs
                        {
                            done.Add(url);
                        }
                    }
                }
            }

            if (regions.Count == 0)
            {
                return;
            }

            Scene        baseScene   = m_EstateModule.Scenes[0];
            UUID         ScopeID     = baseScene.RegionInfo.ScopeID;
            IGridService gridService = baseScene.GridService;

            if (gridService == null)
            {
                return;
            }

            // Send to remote regions
            foreach (UUID regionID in regions)
            {
                GridRegion region = gridService.GetRegionByUUID(ScopeID, regionID);
                if (region != null)
                {
                    string url = region.ExternalHostName + ":" + region.HttpPort;
                    if (done.Contains(url))
                    {
                        continue;
                    }
                    Call(region, sendData);
                    done.Add(url);
                }
            }
        }
示例#10
0
        public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
        {
            GridRegion r = m_localService.GetRegionByUUID(scopeID, regionID);

            if (r == null)
            {
                r = m_remoteService.GetRegionByUUID(scopeID, regionID);
                UpdateGridRegionForIWC(ref r);
            }
            return(r);
        }
示例#11
0
        public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
        {
            GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);

            if (rinfo == null)
            {
                rinfo = base.GetRegionByUUID(scopeID, regionID);
            }

            return(rinfo);
        }
示例#12
0
        public GridRegion GetHyperlinkRegion(UUID regionID, UUID agentID, string agentHomeURI, out string message)
        {
            message = null;

            if (!m_AllowTeleportsToAnyRegion)
            {
                // Don't even check the given regionID
                m_log.DebugFormat(
                    "[GATEKEEPER SERVICE]: Returning gateway region {0} {1} @ {2} to user {3}{4} as teleporting to arbitrary regions is not allowed.",
                    m_DefaultGatewayRegion.RegionName,
                    m_DefaultGatewayRegion.RegionID,
                    m_DefaultGatewayRegion.ServerURI,
                    agentID,
                    agentHomeURI == null ? "" : " @ " + agentHomeURI);

                message = "Teleporting to the default region.";
                return(m_DefaultGatewayRegion);
            }

            GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID);

            if (region == null)
            {
                m_log.DebugFormat(
                    "[GATEKEEPER SERVICE]: Could not find region with ID {0} as requested by user {1}{2}.  Returning null.",
                    regionID, agentID, (agentHomeURI == null) ? "" : " @ " + agentHomeURI);

                message = "The teleport destination could not be found.";
                return(null);
            }

            m_log.DebugFormat(
                "[GATEKEEPER SERVICE]: Returning region {0} {1} @ {2} to user {3}{4}.",
                region.RegionName,
                region.RegionID,
                region.ServerURI,
                agentID,
                agentHomeURI == null ? "" : " @ " + agentHomeURI);

            return(region);
        }
示例#13
0
        public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
        {
            bool inCache = false;
            GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionID, out inCache);
            if (inCache)
                return rinfo;

            rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
            if (rinfo != null)
                m_RegionInfoCache.Cache(scopeID, rinfo);
            return rinfo;
        }
示例#14
0
        bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID, bool foreigner)
        {
            bool       imresult = false;
            GridRegion reginfo  = null;

            if (!m_RegionCache.TryGetValue(upd.RegionID, out reginfo))
            {
                reginfo = m_GridService.GetRegionByUUID(UUID.Zero /*!!!*/, upd.RegionID);
                if (reginfo != null)
                {
                    m_RegionCache.AddOrUpdate(upd.RegionID, reginfo, CACHE_EXPIRATION_SECONDS);
                }
            }

            if (reginfo != null)
            {
                imresult = InstantMessageServiceConnector.SendInstantMessage(reginfo.ServerURI, im, m_messageKey);
            }
            else
            {
                m_log.DebugFormat("[HG IM SERVICE]: Failed to deliver message to {0}", reginfo.ServerURI);
                return(false);
            }

            if (imresult)
            {
                // IM delivery successful, so store the Agent's location in our local cache.
                lock (m_UserLocationMap)
                {
                    if (m_UserLocationMap.ContainsKey(toAgentID))
                    {
                        m_UserLocationMap[toAgentID] = upd;
                    }
                    else
                    {
                        m_UserLocationMap.Add(toAgentID, upd);
                    }
                }
                return(true);
            }
            else
            {
                // try again, but lookup user this time.
                // Warning, this must call the Async version
                // of this method or we'll be making thousands of threads
                // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
                // The version that spawns the thread is SendGridInstantMessageViaXMLRPC

                // This is recursive!!!!!
                return(TrySendInstantMessage(im, upd, false, foreigner));
            }
        }
示例#15
0
        protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, string user, bool online)
        {
            UUID userID;

            if (UUID.TryParse(user, out userID))
            {
                if (m_FriendsLocalSimConnector != null)
                {
                    m_log.DebugFormat("[HGFRIENDS SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline"));
                    m_FriendsLocalSimConnector.StatusNotify(foreignUserID, userID, online);
                }
                else
                {
                    GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID);
                    if (region != null)
                    {
                        m_log.DebugFormat("[HGFRIENDS SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline"));
                        m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID.ToString(), online);
                    }
                }
            }
        }
        public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
        {
            GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);

            if (rinfo != null)
            {
                return(rinfo);
            }

            rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID);
            m_RegionInfoCache.Cache(scopeID, rinfo);
            return(rinfo);
        }
示例#17
0
        private string GetRegionService(UUID regionID)
        {
            IGridService gs = m_registry.RequestModuleInterface <IGridService>();

            if (gs != null && regionID != UUID.Zero)
            {
                GridRegion region = gs.GetRegionByUUID(UUID.Zero, regionID);
                if (region != null)
                {
                    return(region.ServerURI);
                }
            }
            return("NonExistant");
        }
示例#18
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);
        }
示例#19
0
        public GridRegion GetHyperlinkRegion(UUID regionID, UUID agentID, string agentHomeURI, out string message)
        {
            m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get hyperlink region {0} for user {1}{2}",
                              regionID, agentID, (agentHomeURI == null) ? "" : " @ " + agentHomeURI);

            message = null;

            if (!m_AllowTeleportsToAnyRegion)
            {
                // Don't even check the given regionID
                message = "Teleporting to the default region.";
                return(m_DefaultGatewayRegion);
            }

            GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID);

            if (region == null)
            {
                message = "The teleport destination could not be found.";
                return(null);
            }

            return(region);
        }
示例#20
0
        /*		#region IService implementation
         *
         *      public void Initialize(IConfigSource config, IRegistryCore registry)
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         *      public void Start(IConfigSource config, IRegistryCore registry)
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         *      public void FinishedStartup()
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         #endregion
         */

        #region user

        /// <summary>
        /// Gets user information for change user info page on site
        /// </summary>
        /// <param name="map">UUID</param>
        /// <returns>Verified, HomeName, HomeUUID, Online, Email, FirstName, LastName</returns>
        OSDMap GetGridUserInfo(OSDMap map)
        {
            string uuid = string.Empty;

            uuid = map ["UUID"].AsString();

            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> ();
            UserAccount         userAcct       = accountService.GetUserAccount(null, map ["UUID"].AsUUID());
            IAgentInfoService   agentService   = m_registry.RequestModuleInterface <IAgentInfoService> ();

            UserInfo userinfo;
            OSDMap   resp         = new OSDMap();
            bool     usr_verified = userAcct.Valid;

            resp ["Verified"]  = OSD.FromBoolean(usr_verified);
            resp ["UUID"]      = OSD.FromUUID(userAcct.PrincipalID);
            resp ["Email"]     = OSD.FromString(userAcct.Email);
            resp ["Name"]      = OSD.FromString(userAcct.Name);
            resp ["FirstName"] = OSD.FromString(userAcct.FirstName);
            resp ["LastName"]  = OSD.FromString(userAcct.LastName);

            // just some defaults
            resp ["HomeUUID"] = OSD.FromUUID(UUID.Zero);
            resp ["HomeName"] = OSD.FromString("");
            resp ["Online"]   = OSD.FromBoolean(false);


            if (verified)
            {
                userinfo = agentService.GetUserInfo(uuid);
                if (userinfo != null)
                {
                    resp ["HomeUUID"] = OSD.FromUUID(userinfo.HomeRegionID);
                    resp ["Online"]   = OSD.FromBoolean(userinfo.IsOnline);
                }
                IGridService gs = m_registry.RequestModuleInterface <IGridService> ();
                if (gs != null)
                {
                    GridRegion gr = gs.GetRegionByUUID(null, userinfo.HomeRegionID);
                    if (gr != null)
                    {
                        resp ["HomeName"] = OSD.FromString(gr.RegionName);
                    }
                }
            }

            return(resp);
        }
        /// <summary>
        /// Get all the neighboring regions of the given region
        /// </summary>
        /// <param name="region"></param>
        /// <returns></returns>
        private List <GridRegion> FindNewNeighbors(GridRegion region)
        {
            int startX = (int)(region.RegionLocX - 8192); //Give 8196 by default so that we pick up neighbors next to us
            int startY = (int)(region.RegionLocY - 8192);

            if (m_gridService.MaxRegionSize != 0)
            {
                startX = (int)(region.RegionLocX - m_gridService.MaxRegionSize);
                startY = (int)(region.RegionLocY - m_gridService.MaxRegionSize);
            }

            //-1 so that we don't get size (256) + viewsize (256) and get a region two 256 blocks over
            int endX = (region.RegionLocX + RegionViewSize + region.RegionSizeX - 1);
            int endY = (region.RegionLocY + RegionViewSize + region.RegionSizeY - 1);

            List <GridRegion> neighbors = m_gridService.GetRegionRange(region.ScopeID, startX, endX, startY, endY);

            //If we arn't supposed to close local regions, add all of the scene ones if they are not already there
            if (!CloseLocalRegions)
            {
                foreach (Scene scene in m_Scenes)
                {
                    GridRegion gregion = m_gridService.GetRegionByUUID(scene.RegionInfo.ScopeID, scene.RegionInfo.RegionID);
                    if (!neighbors.Contains(gregion))
                    {
                        neighbors.Add(gregion);
                    }
                }
            }
            neighbors.RemoveAll(delegate(GridRegion r)
            {
                if (r.RegionID == region.RegionID)
                {
                    return(true);
                }

                if (r.RegionLocX + r.RegionSizeX - 1 < (region.RegionLocX - RegionViewSize) ||
                    r.RegionLocY + r.RegionSizeY - 1 < (region.RegionLocY - RegionViewSize)) //Check for regions outside of the boundry (created above when checking for large regions next to us)
                {
                    return(true);
                }

                return(false);
            });
            return(neighbors);
        }
        byte[] GetRegionByUUID(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
            }

            UUID regionID = UUID.Zero;

            if (request.ContainsKey("REGIONID"))
            {
                UUID.TryParse(request["REGIONID"].ToString(), out regionID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
            }

            GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
            //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if (rinfo == null)
            {
                result["result"] = "null";
            }
            else
            {
                result["result"] = rinfo.ToKeyValuePairs();
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);
            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
示例#23
0
        public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
        {
            bool       inCache = false;
            GridRegion rinfo   = m_RegionInfoCache.Get(scopeID, regionID, out inCache);

            if (inCache)
            {
                return(rinfo);
            }

            rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
            if (rinfo == null)
            {
                rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID);
            }

            m_RegionInfoCache.Cache(scopeID, regionID, rinfo);
            return(rinfo);
        }
示例#24
0
        /*		#region IService implementation
         *
         *      public void Initialize(IConfigSource config, IRegistryCore registry)
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         *      public void Start(IConfigSource config, IRegistryCore registry)
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         *      public void FinishedStartup()
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         #endregion
         */

        #region user

        /// <summary>
        /// Gets user information for change user info page on site
        /// </summary>
        /// <param name="map">UUID</param>
        /// <returns>Verified, HomeName, HomeUUID, Online, Email, FirstName, LastName</returns>
        OSDMap GetGridUserInfo(OSDMap map)
        {
            string uuid = string.Empty;

            uuid = map ["UUID"].AsString();

            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> ();
            UserAccount         user           = accountService.GetUserAccount(null, map ["UUID"].AsUUID());
            IAgentInfoService   agentService   = m_registry.RequestModuleInterface <IAgentInfoService> ();

            UserInfo userinfo;
            OSDMap   resp     = new OSDMap();
            bool     verified = user != null;

            resp ["Verified"] = OSD.FromBoolean(verified);
            if (verified)
            {
                userinfo = agentService.GetUserInfo(uuid);
                IGridService gs = m_registry.RequestModuleInterface <IGridService> ();
                GridRegion   gr = null;
                if (userinfo != null)
                {
                    gr = gs.GetRegionByUUID(null, userinfo.HomeRegionID);
                }

                resp ["UUID"]      = OSD.FromUUID(user.PrincipalID);
                resp ["HomeUUID"]  = OSD.FromUUID((userinfo == null) ? UUID.Zero : userinfo.HomeRegionID);
                resp ["HomeName"]  = OSD.FromString((userinfo == null) ? "" : gr.RegionName);
                resp ["Online"]    = OSD.FromBoolean((userinfo == null) ? false : userinfo.IsOnline);
                resp ["Email"]     = OSD.FromString(user.Email);
                resp ["Name"]      = OSD.FromString(user.Name);
                resp ["FirstName"] = OSD.FromString(user.FirstName);
                resp ["LastName"]  = OSD.FromString(user.LastName);
            }

            return(resp);
        }
示例#25
0
        bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID, bool foreigner)
        {
            GridRegion reginfo = null;

            if (!m_RegionCache.TryGetValue(upd.RegionID, REGIONCACHE_EXPIRATION, out reginfo))
            {
                reginfo = m_GridService.GetRegionByUUID(UUID.Zero /*!!!*/, upd.RegionID);
                m_RegionCache.AddOrUpdate(upd.RegionID, reginfo, reginfo == null ? 60000 : REGIONCACHE_EXPIRATION);
            }

            if (reginfo == null)
            {
                return(false);
            }

            bool imresult = InstantMessageServiceConnector.SendInstantMessage(reginfo.ServerURI, im, m_messageKey);

            if (imresult)
            {
                // IM delivery successful, so store the Agent's location in our local cache.
                lock (m_UserLocationMap)
                    m_UserLocationMap[toAgentID] = upd;
                return(true);
            }
            else
            {
                // try again, but lookup user this time.
                // Warning, this must call the Async version
                // of this method or we'll be making thousands of threads
                // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
                // The version that spawns the thread is SendGridInstantMessageViaXMLRPC

                // This is recursive!!!!!
                return(TrySendInstantMessage(im, upd, false, foreigner));
            }
        }
        public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID,
                                   string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP)
        {
            bool success = false;
            UUID session = UUID.Random();

            m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}",
                             firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0);

            try
            {
                //
                // Check client
                //
                if (m_AllowedClients != string.Empty)
                {
                    Regex arx = new Regex(m_AllowedClients);
                    Match am  = arx.Match(clientVersion);

                    if (!am.Success)
                    {
                        m_log.InfoFormat(
                            "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: client {2} is not allowed",
                            firstName, lastName, clientVersion);
                        return(LLFailedLoginResponse.LoginBlockedProblem);
                    }
                }

                if (m_DeniedClients != string.Empty)
                {
                    Regex drx = new Regex(m_DeniedClients);
                    Match dm  = drx.Match(clientVersion);

                    if (dm.Success)
                    {
                        m_log.InfoFormat(
                            "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: client {2} is denied",
                            firstName, lastName, clientVersion);
                        return(LLFailedLoginResponse.LoginBlockedProblem);
                    }
                }

                //
                // Get the account and check that it exists
                //
                UserAccount account = m_UserAccountService.GetUserAccount(scopeID, firstName, lastName);
                if (account == null)
                {
                    m_log.InfoFormat(
                        "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: user not found", firstName, lastName);
                    return(LLFailedLoginResponse.UserProblem);
                }

                if (account.UserLevel < m_MinLoginLevel)
                {
                    m_log.InfoFormat(
                        "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: user level is {2} but minimum login level is {3}",
                        firstName, lastName, account.UserLevel, m_MinLoginLevel);
                    return(LLFailedLoginResponse.LoginBlockedProblem);
                }

                // If a scope id is requested, check that the account is in
                // that scope, or unscoped.
                //
                if (scopeID != UUID.Zero)
                {
                    if (account.ScopeID != scopeID && account.ScopeID != UUID.Zero)
                    {
                        m_log.InfoFormat(
                            "[LLOGIN SERVICE]: Login failed, reason: user {0} {1} not found", firstName, lastName);
                        return(LLFailedLoginResponse.UserProblem);
                    }
                }
                else
                {
                    scopeID = account.ScopeID;
                }

                //
                // Authenticate this user
                //
                if (!passwd.StartsWith("$1$"))
                {
                    passwd = "$1$" + Util.Md5Hash(passwd);
                }
                passwd = passwd.Remove(0, 3); //remove $1$
                string token         = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30);
                UUID   secureSession = UUID.Zero;
                if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
                {
                    m_log.InfoFormat(
                        "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: authentication failed",
                        firstName, lastName);
                    return(LLFailedLoginResponse.UserProblem);
                }

                //
                // Get the user's inventory
                //
                if (m_RequireInventory && m_InventoryService == null)
                {
                    m_log.WarnFormat(
                        "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: inventory service not set up",
                        firstName, lastName);
                    return(LLFailedLoginResponse.InventoryProblem);
                }

                if (m_HGInventoryService != null)
                {
                    // Give the Suitcase service a chance to create the suitcase folder.
                    // (If we're not using the Suitcase inventory service then this won't do anything.)
                    m_HGInventoryService.GetRootFolder(account.PrincipalID);
                }

                List <InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
                if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
                {
                    m_log.InfoFormat(
                        "[LLOGIN SERVICE]: Login failed, for {0} {1}, reason: unable to retrieve user inventory",
                        firstName, lastName);
                    return(LLFailedLoginResponse.InventoryProblem);
                }

                // Get active gestures
                List <InventoryItemBase> gestures = m_InventoryService.GetActiveGestures(account.PrincipalID);
//                m_log.DebugFormat("[LLOGIN SERVICE]: {0} active gestures", gestures.Count);

                //
                // Login the presence
                //
                if (m_PresenceService != null)
                {
                    success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);

                    if (!success)
                    {
                        m_log.InfoFormat(
                            "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: could not login presence",
                            firstName, lastName);
                        return(LLFailedLoginResponse.GridProblem);
                    }
                }

                //
                // Change Online status and get the home region
                //
                GridRegion   home   = null;
                GridUserInfo guinfo = m_GridUserService.LoggedIn(account.PrincipalID.ToString());

                // We are only going to complain about no home if the user actually tries to login there, to avoid
                // spamming the console.
                if (guinfo != null)
                {
                    if (guinfo.HomeRegionID == UUID.Zero && startLocation == "home")
                    {
                        m_log.WarnFormat(
                            "[LLOGIN SERVICE]: User {0} tried to login to a 'home' start location but they have none set",
                            account.Name);
                    }
                    else if (m_GridService != null)
                    {
                        home = m_GridService.GetRegionByUUID(scopeID, guinfo.HomeRegionID);

                        if (home == null && startLocation == "home")
                        {
                            m_log.WarnFormat(
                                "[LLOGIN SERVICE]: User {0} tried to login to a 'home' start location with ID {1} but this was not found.",
                                account.Name, guinfo.HomeRegionID);
                        }
                    }
                }
                else
                {
                    // something went wrong, make something up, so that we don't have to test this anywhere else
                    m_log.DebugFormat("{0} Failed to fetch GridUserInfo. Creating empty GridUserInfo as home", LogHeader);
                    guinfo = new GridUserInfo();
                    guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30);
                }

                //
                // Find the destination region/grid
                //
                string where = string.Empty;
                Vector3       position   = Vector3.Zero;
                Vector3       lookAt     = Vector3.Zero;
                GridRegion    gatekeeper = null;
                TeleportFlags flags;
                GridRegion    destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out gatekeeper, out where, out position, out lookAt, out flags);
                if (destination == null)
                {
                    m_PresenceService.LogoutAgent(session);

                    m_log.InfoFormat(
                        "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: destination not found",
                        firstName, lastName);
                    return(LLFailedLoginResponse.GridProblem);
                }
                else
                {
                    m_log.DebugFormat(
                        "[LLOGIN SERVICE]: Found destination {0}, endpoint {1} for {2} {3}",
                        destination.RegionName, destination.ExternalEndPoint, firstName, lastName);
                }

                if (account.UserLevel >= 200)
                {
                    flags |= TeleportFlags.Godlike;
                }
                //
                // Get the avatar
                //
                AvatarAppearance avatar = null;
                if (m_AvatarService != null)
                {
                    avatar = m_AvatarService.GetAppearance(account.PrincipalID);
                }

                //
                // Instantiate/get the simulation interface and launch an agent at the destination
                //
                string           reason = string.Empty;
                GridRegion       dest;
                AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where,
                                                              clientVersion, channel, mac, id0, clientIP, flags, out where, out reason, out dest);
                destination = dest;
                if (aCircuit == null)
                {
                    m_PresenceService.LogoutAgent(session);
                    m_log.InfoFormat("[LLOGIN SERVICE]: Login failed for {0} {1}, reason: {2}", firstName, lastName, reason);
                    return(new LLFailedLoginResponse("key", reason, "false"));
                }
                // Get Friends list
                FriendInfo[] friendsList = new FriendInfo[0];
                if (m_FriendsService != null)
                {
                    friendsList = m_FriendsService.GetFriends(account.PrincipalID);
//                    m_log.DebugFormat("[LLOGIN SERVICE]: Retrieved {0} friends", friendsList.Length);
                }

                //
                // Finally, fill out the response and return it
                //
                LLLoginResponse response
                    = new LLLoginResponse(
                          account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService,
                          where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP,
                          m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone,
                          m_DestinationGuide, m_AvatarPicker, m_ClassifiedFee);

                m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName);

                return(response);
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2} {3}", firstName, lastName, e.ToString(), e.StackTrace);
                if (m_PresenceService != null)
                {
                    m_PresenceService.LogoutAgent(session);
                }
                return(LLFailedLoginResponse.InternalError);
            }
        }
        /// <summary>
        /// Shows estate regions.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void ShowEstateRegionsCommand(IScene scene, string [] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            IGridService     gridService     = m_registry.RequestModuleInterface <IGridService> ();

            // check for passed estate name
            string estateName;

            if (cmd.Length < 4)
            {
                do
                {
                    estateName = MainConsole.Instance.Prompt("Estate name (? for list)", "");
                    if (estateName == "?")
                    {
                        var estates = estateConnector.GetEstateNames();
                        MainConsole.Instance.CleanInfo(" Available estates are : ");
                        foreach (string estate in estates)
                        {
                            MainConsole.Instance.CleanInfo("    " + estate);
                        }
                    }
                } while (estateName == "?");

                if (estateName == "")
                {
                    return;
                }
            }
            else
            {
                estateName = cmd [3];
            }

            // verify that the estate does exist
            EstateSettings ES = estateConnector.GetEstateSettings(estateName);

            if (ES == null)
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist!", estateName);
                return;
            }

            var estateregions = estateConnector.GetRegions((int)ES.EstateID);

            int   estRegions = 0;
            float estateArea = 0;
            int   offLine    = 0;

            string regionInfo;

            regionInfo  = string.Format("{0, -20}", "Region");
            regionInfo += string.Format("{0, -12}", "Location");
            regionInfo += string.Format("{0, -14}", "Size");
            regionInfo += string.Format("{0, -12}", "Area");
            regionInfo += string.Format("{0, -26}", "Type");
            regionInfo += string.Format("{0, -10}", "Online");

            MainConsole.Instance.CleanInfo(regionInfo);

            MainConsole.Instance.CleanInfo(
                "----------------------------------------------------------------------------------------------------");

            foreach (UUID regionID in estateregions)
            {
                var region = gridService.GetRegionByUUID(null, regionID);
                if (region == null)     // deleted??
                {
                    continue;
                }

                estRegions++;
                estateArea = estateArea + region.RegionArea;


                if (!region.IsOnline)
                {
                    offLine++;
                }

                // TODO ... change hardcoded field sizes to public constants
                regionInfo  = string.Format("{0, -20}", region.RegionName);
                regionInfo += string.Format("{0, -12}", region.RegionLocX / Constants.RegionSize + "," + region.RegionLocY / Constants.RegionSize);
                regionInfo += string.Format("{0, -14}", region.RegionSizeX + "x" + region.RegionSizeY);
                regionInfo += string.Format("{0, -12}", region.RegionArea < 1000000 ? region.RegionArea + " m2" : (region.RegionArea / 1000000) + " km2");
                regionInfo += string.Format("{0, -26}", region.RegionType);
                regionInfo += string.Format("{0, -10}", region.IsOnline ? "yes" : "no");

                MainConsole.Instance.CleanInfo(regionInfo);
            }
            MainConsole.Instance.CleanInfo("");
            MainConsole.Instance.CleanInfo(
                "----------------------------------------------------------------------------------------------------");
            MainConsole.Instance.CleanInfo("Regions : " + estRegions + " regions with an area of " + (estateArea / 1000000) + " km2");
            MainConsole.Instance.CleanInfo("Offline : " + offLine);
            MainConsole.Instance.CleanInfo(string.Empty);
            MainConsole.Instance.CleanInfo(
                "----------------------------------------------------------------------------------------------------");
            MainConsole.Instance.CleanInfo("\n");
        }
示例#28
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            UserAccount account = null;

            if (httpRequest.Query.ContainsKey("regionid"))
            {
                var regionService = webInterface.Registry.RequestModuleInterface <IGridService> ();
                var region        = regionService.GetRegionByUUID(null, UUID.Parse(httpRequest.Query ["regionid"].ToString()));

                UUID userid = region.EstateOwner;

                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, userid);
            }

            if (account == null)
            {
                return(vars);
            }

            vars.Add("UserName", account.Name);

            //  TODO: User Profile inworld shows this as the standard mm/dd/yyyy
            //  Do we want this to be localised into the users Localisation or keep it as standard ?
            vars.Add("UserBorn", Util.ToDateTime(account.Created).ToShortDateString());

            IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>().GetUserProfile(account.PrincipalID);

            if (profile != null)
            {
                vars.Add("UserType", profile.MembershipGroup == "" ? "Resident" : profile.MembershipGroup);

                if (profile != null)
                {
                    if (profile.Partner != UUID.Zero)
                    {
                        account = webInterface.Registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, profile.Partner);
                        vars.Add("UserPartner", account.Name);
                    }
                    else
                    {
                        vars.Add("UserPartner", "No partner");
                    }

                    vars.Add("UserAboutMe", profile.AboutText == "" ? "Nothing here" : profile.AboutText);

                    string url = "../images/icons/no_avatar.jpg";
                    IWebHttpTextureService webhttpService = webInterface.Registry.RequestModuleInterface <IWebHttpTextureService> ();

                    if (webhttpService != null && profile.Image != UUID.Zero)
                    {
                        url = webhttpService.GetTextureURL(profile.Image);
                    }

                    vars.Add("UserPictureURL", url);
                }
            }
            else
            {
                // no profile yet for this user
                vars.Add("UserType", "Unknown");
                vars.Add("UserPartner", "Unknown");
                vars.Add("UserPictureURL", "../images/icons/no_avatar.jpg");
            }

            UserAccount ourAccount = Authenticator.GetAuthentication(httpRequest);

            if (ourAccount != null)
            {
                IFriendsService friendsService = webInterface.Registry.RequestModuleInterface <IFriendsService>();
                var             friends        = friendsService.GetFriends(account.PrincipalID);
                UUID            friendID       = UUID.Zero;

                if (friends.Any(f => UUID.TryParse(f.Friend, out friendID) && friendID == ourAccount.PrincipalID))
                {
                    IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService>();
                    IGridService      gridService      = webInterface.Registry.RequestModuleInterface <IGridService>();
                    UserInfo          ourInfo          = agentInfoService.GetUserInfo(account.PrincipalID.ToString());

                    if (ourInfo != null && ourInfo.IsOnline)
                    {
                        vars.Add("OnlineLocation", gridService.GetRegionByUUID(null, ourInfo.CurrentRegionID).RegionName);
                    }

                    vars.Add("UserIsOnline", ourInfo != null && ourInfo.IsOnline);
                    vars.Add("IsOnline", ourInfo != null && ourInfo.IsOnline
                                 ? translator.GetTranslatedString("Online")
                                 : translator.GetTranslatedString("Offline"));
                }
                else
                {
                    vars.Add("OnlineLocation", "");
                    vars.Add("UserIsOnline", false);
                    vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
                }
            }
            else
            {
                vars.Add("OnlineLocation", "");
                vars.Add("UserIsOnline", false);
                vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
            }

            vars.Add("UserProfileFor", translator.GetTranslatedString("UserProfileFor"));
            vars.Add("ResidentSince", translator.GetTranslatedString("ResidentSince"));
            vars.Add("AccountType", translator.GetTranslatedString("AccountType"));
            vars.Add("PartnersName", translator.GetTranslatedString("PartnersName"));
            vars.Add("AboutMe", translator.GetTranslatedString("AboutMe"));
            vars.Add("IsOnlineText", translator.GetTranslatedString("IsOnlineText"));
            vars.Add("OnlineLocationText", translator.GetTranslatedString("OnlineLocationText"));

            return(vars);
        }
示例#29
0
        public bool CrossAgent(GridRegion crossingRegion, Vector3 pos,
                               Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, UUID AgentID, ulong requestingRegion, out string reason)
        {
            try
            {
                IClientCapsService       clientCaps           = m_registry.RequestModuleInterface <ICapsService>().GetClientCapsService(AgentID);
                IRegionClientCapsService requestingRegionCaps = clientCaps.GetCapsService(requestingRegion);
                ISimulationService       SimulationService    = m_registry.RequestModuleInterface <ISimulationService>();
                if (SimulationService != null)
                {
                    //Note: we have to pull the new grid region info as the one from the region cannot be trusted
                    IGridService GridService = m_registry.RequestModuleInterface <IGridService>();
                    if (GridService != null)
                    {
                        //Set the user in transit so that we block duplicate tps and reset any cancelations
                        if (!SetUserInTransit(AgentID))
                        {
                            reason = "Already in a teleport";
                            return(false);
                        }

                        bool result = false;

                        crossingRegion = GridService.GetRegionByUUID(UUID.Zero, crossingRegion.RegionID);
                        if (!SimulationService.UpdateAgent(crossingRegion, cAgent))
                        {
                            m_log.Warn("[AgentProcessing]: Failed to cross agent " + AgentID + " because region did not accept it. Resetting.");
                            reason = "Failed to update an agent";
                        }
                        else
                        {
                            IEventQueueService EQService = m_registry.RequestModuleInterface <IEventQueueService>();

                            //Add this for the viewer, but not for the sim, seems to make the viewer happier
                            int XOffset = crossingRegion.RegionLocX - requestingRegionCaps.RegionX;
                            pos.X += XOffset;

                            int YOffset = crossingRegion.RegionLocY - requestingRegionCaps.RegionY;
                            pos.Y += YOffset;

                            IRegionClientCapsService otherRegion = clientCaps.GetCapsService(crossingRegion.RegionHandle);
                            //Tell the client about the transfer
                            EQService.CrossRegion(crossingRegion.RegionHandle, pos, velocity, crossingRegion.ExternalEndPoint, otherRegion.CapsUrl,
                                                  AgentID, circuit.SessionID,
                                                  crossingRegion.RegionSizeX, crossingRegion.RegionSizeY,
                                                  requestingRegion);

                            result = WaitForCallback(AgentID);
                            if (!result)
                            {
                                m_log.Warn("[AgentProcessing]: Callback never came in crossing agent " + circuit.AgentID + ". Resetting.");
                                reason = "Crossing timed out";
                            }
                            else
                            {
                                // Next, let's close the child agent connections that are too far away.
                                INeighborService service = m_registry.RequestModuleInterface <INeighborService>();
                                if (service != null)
                                {
                                    //Fix the root agent status
                                    otherRegion.RootAgent          = true;
                                    requestingRegionCaps.RootAgent = false;

                                    CloseNeighborAgents(requestingRegionCaps.Region, crossingRegion, AgentID);
                                }
                                reason = "";
                            }
                        }

                        //All done
                        ResetFromTransit(AgentID);
                        return(result);
                    }
                    else
                    {
                        reason = "Could not find the GridService";
                    }
                }
                else
                {
                    reason = "Could not find the SimulationService";
                }
            }
            catch (Exception ex)
            {
                m_log.WarnFormat("[AgentProcessing]: Failed to cross an agent into a new region. {0}", ex.ToString());
            }
            ResetFromTransit(AgentID);
            reason = "Exception occured";
            return(false);
        }
示例#30
0
        public bool TeleportAgent(GridRegion destination, uint TeleportFlags, int DrawDistance,
                                  AgentCircuitData circuit, AgentData agentData, UUID AgentID, ulong requestingRegion,
                                  out string reason)
        {
            IClientCapsService       clientCaps = m_registry.RequestModuleInterface <ICapsService>().GetClientCapsService(AgentID);
            IRegionClientCapsService regionCaps = clientCaps.GetCapsService(requestingRegion);

            if (regionCaps == null || !regionCaps.RootAgent)
            {
                reason = "";
                return(false);
            }

            bool result = false;

            try
            {
                bool callWasCanceled = false;

                ISimulationService SimulationService = m_registry.RequestModuleInterface <ISimulationService>();
                if (SimulationService != null)
                {
                    //Set the user in transit so that we block duplicate tps and reset any cancelations
                    if (!SetUserInTransit(AgentID))
                    {
                        reason = "Already in a teleport";
                        return(false);
                    }

                    //Note: we have to pull the new grid region info as the one from the region cannot be trusted
                    IGridService GridService = m_registry.RequestModuleInterface <IGridService>();
                    if (GridService != null)
                    {
                        destination = GridService.GetRegionByUUID(UUID.Zero, destination.RegionID);
                        //Inform the client of the neighbor if needed
                        circuit.child = false; //Force child status to the correct type

                        if (!InformClientOfNeighbor(AgentID, requestingRegion, circuit, destination, TeleportFlags,
                                                    agentData, out reason))
                        {
                            ResetFromTransit(AgentID);
                            return(false);
                        }
                    }
                    else
                    {
                        reason = "Could not find the grid service";
                        ResetFromTransit(AgentID);
                        return(false);
                    }

                    IEventQueueService EQService = m_registry.RequestModuleInterface <IEventQueueService>();

                    IRegionClientCapsService otherRegion = clientCaps.GetCapsService(destination.RegionHandle);

                    EQService.TeleportFinishEvent(destination.RegionHandle, destination.Access, destination.ExternalEndPoint, otherRegion.CapsUrl,
                                                  4, AgentID, TeleportFlags,
                                                  destination.RegionSizeX, destination.RegionSizeY,
                                                  requestingRegion);

                    // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
                    // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
                    // that the client contacted the destination before we send the attachments and close things here.

                    result = WaitForCallback(AgentID, out callWasCanceled);
                    if (!result)
                    {
                        //It says it failed, lets call the sim and check
                        IAgentData data = null;
                        result = SimulationService.RetrieveAgent(destination, AgentID, out data);
                    }
                    if (!result)
                    {
                        if (!callWasCanceled)
                        {
                            m_log.Warn("[AgentProcessing]: Callback never came for teleporting agent " +
                                       AgentID + ". Resetting.");
                        }
                        INeighborService service = m_registry.RequestModuleInterface <INeighborService>();
                        if (service != null)
                        {
                            //Close the agent at the place we just created if it isn't a neighbor
                            if (service.IsOutsideView(regionCaps.RegionX, destination.RegionLocX, regionCaps.Region.RegionSizeX, destination.RegionSizeX,
                                                      regionCaps.RegionY, destination.RegionLocY, regionCaps.Region.RegionSizeY, destination.RegionSizeY))
                            {
                                SimulationService.CloseAgent(destination, AgentID);
                            }
                        }
                        clientCaps.RemoveCAPS(destination.RegionHandle);
                        if (!callWasCanceled)
                        {
                            reason = "The teleport timed out";
                        }
                        else
                        {
                            reason = "Cancelled";
                        }
                    }
                    else
                    {
                        //Fix the root agent status
                        otherRegion.RootAgent = true;
                        regionCaps.RootAgent  = false;

                        // Next, let's close the child agent connections that are too far away.
                        CloseNeighborAgents(regionCaps.Region, destination, AgentID);
                        reason = "";
                    }
                }
                else
                {
                    reason = "No SimulationService found!";
                }
            }
            catch (Exception ex)
            {
                m_log.WarnFormat("[AgentProcessing]: Exception occured during agent teleport, {0}", ex.ToString());
                reason = "Exception occured.";
            }
            //All done
            ResetFromTransit(AgentID);
            return(result);
        }