Ejemplo n.º 1
0
        public OSDMap GetExternalCaps(UUID agentID, GridRegion region)
        {
            if (m_registry == null) return new OSDMap();
            OSDMap resp = new OSDMap();
            if (m_registry.RequestModuleInterface<IGridServerInfoService>() != null)
            {
                m_servers = m_registry.RequestModuleInterface<IGridServerInfoService>().GetGridURIs("SyncMessageServerURI");
                OSDMap req = new OSDMap();
                req["AgentID"] = agentID;
                req["Region"] = region.ToOSD();
                req["Method"] = "GetCaps";

                List<ManualResetEvent> events = new List<ManualResetEvent>();
                foreach (string uri in m_servers)
                {
                    ManualResetEvent even = new ManualResetEvent(false);
                    m_syncPoster.Get(uri, req, (r) =>
                    {
                        if (r == null)
                            return;
                        foreach (KeyValuePair<string, OSD> kvp in r)
                            resp.Add(kvp.Key, kvp.Value);
                        even.Set();
                    });
                    events.Add(even);
                }
                ManualResetEvent.WaitAll(events.ToArray());
            }
            foreach (var h in GetHandlers(agentID, region.RegionID))
            {
                if (m_allowedCapsModules.Contains(h.Name))
                    h.IncomingCapsRequest(agentID, region, m_registry.RequestModuleInterface<ISimulationBase>(), ref resp);
            }
            return resp;
        }
        public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out CreateAgentResponse response)
        {
            response = null;
            CreateAgentRequest request = new CreateAgentRequest();
            request.CircuitData = aCircuit;
            request.Destination = destination;
            request.TeleportFlags = teleportFlags;

            AutoResetEvent resetEvent = new AutoResetEvent(false);
            OSDMap result = null;
            m_syncMessagePoster.Get(destination.ServerURI, request.ToOSD(), (osdresp) =>
            {
                result = osdresp;
                resetEvent.Set();
            });
            bool success = resetEvent.WaitOne(10000);
            if (!success || result == null)
            {
                response = new CreateAgentResponse();
                response.Reason = "Could not connect to destination";
                response.Success = false;
                return false;
            }

            response = new CreateAgentResponse();
            response.FromOSD(result);

            if (!response.Success)
                return false;
            return response.Success;
        }
        public void TrackAgent(IClientAPI client, UUID hunter, UUID target)
        {
            bool isFriend = IsFriendOfUser(target, hunter);

            if (isFriend)
            {
                IFriendsModule module = m_Scene.RequestModuleInterface <IFriendsModule>();
                if (module != null)
                {
                    int perms = module.GetFriendPerms(hunter, target);
                    if ((perms & (int)FriendRights.CanSeeOnMap) == (int)FriendRights.CanSeeOnMap)
                    {
                        UserInfo GUI =
                            client.Scene.RequestModuleInterface <IAgentInfoService>().GetUserInfo(target.ToString());
                        if (GUI != null && GUI.IsOnline)
                        {
                            GridRegion region = m_Scene.GridService.GetRegionByUUID(
                                client.AllScopeIDs, GUI.CurrentRegionID);

                            client.SendScriptTeleportRequest(client.Name, region.RegionName,
                                                             GUI.CurrentPosition,
                                                             GUI.CurrentLookAt);
                        }
                    }
                }
            }
        }
        /**
         * Agent-related communications
         */
        public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out CreateAgentResponse response)
        {
            response = new CreateAgentResponse();
            IScene Scene = destination == null ? null : GetScene(destination.RegionID);
            if (destination == null || Scene == null)
            {
                response.Reason = "Given destination was null";
                response.Success = false;
                return false;
            }

            if (Scene.RegionInfo.RegionID != destination.RegionID)
            {
                response.Reason = "Did not find region " + destination.RegionName;;
                response.Success = false;
                return false;
            }
            IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
            if (transferModule != null)
                return transferModule.NewUserConnection(Scene, aCircuit, teleportFlags, out response);

            response.Reason = "Did not find region " + destination.RegionName;
            response.Success = false;
            return false;
        }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
        protected List <GridRegion> ParseQuery(List <UUID> scopeIDs, List <string> query)
        {
            List <GridRegion> regionData = new List <GridRegion>();

            if ((query.Count % 14) == 0)
            {
                for (int i = 0; i < query.Count; i += 14)
                {
                    GridRegion data = new GridRegion();
                    OSDMap     map  = (OSDMap)OSDParser.DeserializeJson(query[i + 13]);
                    map["owner_uuid"] = (!map.ContainsKey("owner_uuid") || map["owner_uuid"].AsUUID() == UUID.Zero)
                                            ? OSD.FromUUID(UUID.Parse(query[i + 6]))
                                            : map["owner_uuid"];
                    map["EstateOwner"] = (!map.ContainsKey("EstateOwner") || map["EstateOwner"].AsUUID() == UUID.Zero)
                                             ? OSD.FromUUID(UUID.Parse(query[i + 6]))
                                             : map["EstateOwner"];
                    data.FromOSD(map);

                    if (!regionData.Contains(data))
                    {
                        regionData.Add(data);
                    }
                }
            }

            return(AllScopeIDImpl.CheckScopeIDs(scopeIDs, regionData));
        }
        public bool RetrieveAgent(GridRegion destination, UUID agentID, bool agentIsLeaving, out AgentData agentData,
                                  out AgentCircuitData circuitData)
        {
            agentData   = null;
            circuitData = null;

            RetrieveAgentRequest request = new RetrieveAgentRequest();

            request.AgentID        = agentID;
            request.Destination    = destination;
            request.AgentIsLeaving = agentIsLeaving;

            AutoResetEvent resetEvent = new AutoResetEvent(false);
            OSDMap         result     = null;

            m_syncMessagePoster.Get(destination.ServerURI, request.ToOSD(), (osdresp) =>
            {
                result = osdresp;
                resetEvent.Set();
            });
            bool success = resetEvent.WaitOne(10000);

            if (!success)
            {
                return(false);
            }

            RetrieveAgentResponse response = new RetrieveAgentResponse();

            response.FromOSD(result);

            circuitData = response.CircuitData;
            agentData   = response.AgentData;
            return(response.Success);
        }
Ejemplo n.º 8
0
        public virtual void Teleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt,
                                     uint teleportFlags)
        {
            sp.ControllingClient.SendTeleportStart(teleportFlags);
            sp.ControllingClient.SendTeleportProgress(teleportFlags, "requesting");

            // Reset animations; the viewer does that in teleports.
            if (sp.Animator != null)
            {
                sp.Animator.ResetAnimations();
            }

            try
            {
                string reason = "";
                if (finalDestination.RegionHandle == sp.Scene.RegionInfo.RegionHandle)
                {
                    //First check whether the user is allowed to move at all
                    if (!sp.Scene.Permissions.AllowedOutgoingLocalTeleport(sp.UUID, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    //Now respect things like parcel bans with this
                    if (
                        !sp.Scene.Permissions.AllowedIncomingTeleport(sp.UUID, position, teleportFlags, out position,
                                                                      out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    MainConsole.Instance.DebugFormat(
                        "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}",
                        position, sp.Scene.RegionInfo.RegionName);

                    sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
                    sp.RequestModuleInterface <IScriptControllerModule>()
                    .HandleForceReleaseControls(sp.ControllingClient, sp.UUID);
                    sp.Teleport(position);
                }
                else // Another region possibly in another simulator
                {
                    // Make sure the user is allowed to leave this region
                    if (!sp.Scene.Permissions.AllowedOutgoingRemoteTeleport(sp.UUID, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }

                    DoTeleport(sp, finalDestination, position, lookAt, teleportFlags);
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message,
                                                 e.StackTrace);
                sp.ControllingClient.SendTeleportFailed("Internal error");
            }
        }
 public bool CloseAgent(GridRegion destination, UUID agentID)
 {
     CloseAgentRequest request = new CloseAgentRequest();
     request.AgentID = agentID;
     request.Destination = destination;
     m_syncMessagePoster.Post(destination.ServerURI, request.ToOSD());
     return true;
 }
        public bool CloseAgent(GridRegion destination, UUID agentID)
        {
            CloseAgentRequest request = new CloseAgentRequest();

            request.AgentID     = agentID;
            request.Destination = destination;
            m_syncMessagePoster.Post(destination.ServerURI, request.ToOSD());
            return(true);
        }
Ejemplo n.º 11
0
 public override void FromOSD(OSDMap map)
 {
     AgentID     = map["AgentID"];
     Destination = new GridRegion();
     Destination.FromOSD((OSDMap)map["Destination"]);
     IsCrossing     = map["IsCrossing"];
     Reason         = map["Reason"];
     FailedRegionID = map["FailedRegionID"];
 }
Ejemplo n.º 12
0
 /// <summary>
 ///     Define equality as two regions having the same, non-zero UUID.
 /// </summary>
 public bool Equals(GridRegion region)
 {
     if (region == null)
     {
         return(false);
     }
     // Return true if the non-zero UUIDs are equal:
     return((RegionID != UUID.Zero) && RegionID.Equals(region.RegionID));
 }
        public bool UpdateAgent(GridRegion destination, AgentPosition data)
        {
            if (m_blackListedRegions.ContainsKey(destination.ServerURI))
            {
                //Check against time
                if (m_blackListedRegions[destination.ServerURI] > 3 &&
                    Util.EnvironmentTickCountSubtract(m_blackListedRegions[destination.ServerURI]) > 0)
                {
                    MainConsole.Instance.Warn("[SimServiceConnector]: Blacklisted region " + destination.RegionName +
                                              " requested");
                    //Still blacklisted
                    return(false);
                }
            }

            UpdateAgentPositionRequest request = new UpdateAgentPositionRequest();

            request.Update      = data;
            request.Destination = destination;

            AutoResetEvent resetEvent = new AutoResetEvent(false);
            OSDMap         result     = null;

            m_syncMessagePoster.Get(destination.ServerURI, request.ToOSD(), (response) =>
            {
                result = response;
                resetEvent.Set();
            });
            bool success = resetEvent.WaitOne(10000) && result != null;

            if (!success)
            {
                if (m_blackListedRegions.ContainsKey(destination.ServerURI))
                {
                    if (m_blackListedRegions[destination.ServerURI] == 3)
                    {
                        //add it to the blacklist as the request completely failed 3 times
                        m_blackListedRegions[destination.ServerURI] = Util.EnvironmentTickCount() + 60 * 1000; //60 seconds
                    }
                    else if (m_blackListedRegions[destination.ServerURI] == 0)
                    {
                        m_blackListedRegions[destination.ServerURI]++;
                    }
                }
                else
                {
                    m_blackListedRegions[destination.ServerURI] = 0;
                }
                return(false);
            }

            //Clear out the blacklist if it went through
            m_blackListedRegions.Remove(destination.ServerURI);

            return(result["Success"].AsBoolean());
        }
Ejemplo n.º 14
0
        public bool SendGridMessageRegionPostHandler(Aurora.Framework.Services.GridRegion region, UUID agentID, string message, UUID transactionID)
        {
            OSDMap map = new OSDMap();

            map["AgentID"]       = agentID;
            map["Message"]       = message;
            map["TransactionID"] = transactionID;
            m_syncMessagePosterService.Post(region.ServerURI, map);
            return(true);
        }
        public bool FailedToMoveAgentIntoNewRegion(UUID AgentID, GridRegion destination)
        {
            FailedToMoveAgentIntoNewRegionRequest request = new FailedToMoveAgentIntoNewRegionRequest();

            request.AgentID  = AgentID;
            request.RegionID = destination.RegionID;

            m_syncMessagePoster.Post(destination.ServerURI, request.ToOSD());
            return(true);
        }
Ejemplo n.º 16
0
 public bool IsAuthorizedForRegion(GridRegion region, AgentCircuitData agent, bool isRootAgent, out string reason)
 {
     ISceneManager manager = m_registry.RequestModuleInterface<ISceneManager>();
     if (manager != null && manager.Scene != null && manager.Scene.RegionInfo.RegionID == region.RegionID)
     {
         //Found the region, check permissions
         return manager.Scene.Permissions.AllowedIncomingAgent(agent, isRootAgent, out reason);
     }
     reason = "Not Authorized as region does not exist.";
     return false;
 }
        public bool CloseAgent(GridRegion destination, UUID agentID)
        {
            IScene Scene = destination == null ? null : GetScene(destination.RegionID);
            if (Scene == null || destination == null)
                return false;

            IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
            if (transferModule != null)
                return transferModule.IncomingCloseAgent(Scene, agentID);
            return false;
        }
Ejemplo n.º 18
0
        public bool MakeChildAgent(UUID AgentID, GridRegion destination, bool isCrossing)
        {
            MakeChildAgentRequest request = new MakeChildAgentRequest();

            request.AgentID     = AgentID;
            request.Destination = destination;
            request.IsCrossing  = isCrossing;

            m_syncMessagePoster.Post(destination.ServerURI, request.ToOSD());
            return(true);
        }
Ejemplo n.º 19
0
        private void FillOutRegionData(AgentCircuitData circuitData, GridRegion destination)
        {
            IPEndPoint endPoint = destination.ExternalEndPoint;

            //We don't need this anymore, we set this from what we get from the region
            SimAddress  = endPoint.Address.ToString();
            SimPort     = (uint)circuitData.RegionUDPPort;
            RegionX     = (uint)destination.RegionLocX;
            RegionY     = (uint)destination.RegionLocY;
            RegionSizeX = destination.RegionSizeX;
            RegionSizeY = destination.RegionSizeY;
        }
        public bool FailedToTeleportAgent(GridRegion destination, UUID failedRegionID, UUID AgentID, string reason,
                                          bool isCrossing)
        {
            FailedToTeleportAgentRequest request = new FailedToTeleportAgentRequest();

            request.AgentID        = AgentID;
            request.Destination    = destination;
            request.IsCrossing     = isCrossing;
            request.FailedRegionID = failedRegionID;
            request.Reason         = reason;

            m_syncMessagePoster.Post(destination.ServerURI, request.ToOSD());
            return(true);
        }
Ejemplo n.º 21
0
        public List <GridRegion> GetNeighbours(UUID regionID, List <UUID> scopeIDs, uint squareRangeFromCenterInMeters)
        {
            List <GridRegion> regions = new List <GridRegion>(0);
            GridRegion        region  = Get(regionID, scopeIDs);

            if (region != null)
            {
                int centerX = region.RegionLocX + (region.RegionSizeX / 2); // calculate center of region
                int centerY = region.RegionLocY + (region.RegionSizeY / 2); // calculate center of region

                regions = Get(scopeIDs, region.RegionID, centerX, centerY, squareRangeFromCenterInMeters);
            }

            return(regions);
        }
        public bool CloseAgent(GridRegion destination, UUID agentID)
        {
            if (Scene == null || destination == null)
            {
                return(false);
            }

            IEntityTransferModule transferModule = Scene.RequestModuleInterface <IEntityTransferModule>();

            if (transferModule != null)
            {
                return(transferModule.IncomingCloseAgent(Scene, agentID));
            }
            return(false);
        }
Ejemplo n.º 23
0
        public OSDMap GetExternalCaps(UUID agentID, GridRegion region)
        {
            if (m_registry == null)
            {
                return(new OSDMap());
            }
            OSDMap resp = new OSDMap();

            if (m_registry.RequestModuleInterface <IGridServerInfoService>() != null)
            {
                m_servers = m_registry.RequestModuleInterface <IGridServerInfoService>().GetGridURIs("SyncMessageServerURI");
                OSDMap req = new OSDMap();
                req["AgentID"] = agentID;
                req["Region"]  = region.ToOSD();
                req["Method"]  = "GetCaps";

                List <ManualResetEvent> events = new List <ManualResetEvent>();
                foreach (string uri in m_servers.Where((u) => (!u.Contains(MainServer.Instance.Port.ToString()))))
                {
                    ManualResetEvent even = new ManualResetEvent(false);
                    m_syncPoster.Get(uri, req, (r) =>
                    {
                        if (r == null)
                        {
                            return;
                        }
                        foreach (KeyValuePair <string, OSD> kvp in r)
                        {
                            resp.Add(kvp.Key, kvp.Value);
                        }
                        even.Set();
                    });
                    events.Add(even);
                }
                if (events.Count > 0)
                {
                    ManualResetEvent.WaitAll(events.ToArray());
                }
            }
            foreach (var h in GetHandlers(agentID, region.RegionID))
            {
                if (m_allowedCapsModules.Contains(h.Name))
                {
                    h.IncomingCapsRequest(agentID, region, m_registry.RequestModuleInterface <ISimulationBase>(), ref resp);
                }
            }
            return(resp);
        }
        public bool MakeChildAgent(UUID AgentID, GridRegion destination, bool isCrossing)
        {
            if (Scene == null)
            {
                return(false);
            }

            IEntityTransferModule transferModule = Scene.RequestModuleInterface <IEntityTransferModule>();

            if (transferModule == null)
            {
                return(false);
            }
            transferModule.MakeChildAgent(Scene.GetScenePresence(AgentID), destination, isCrossing);
            return(true);
        }
Ejemplo n.º 25
0
        /// <summary>
        ///     Tries to teleport agent to other region.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="regionName"></param>
        /// <param name="position"></param>
        /// <param name="lookat"></param>
        /// <param name="teleportFlags"></param>
        public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
                                            Vector3 lookat, uint teleportFlags)
        {
            GridRegion regionInfo =
                remoteClient.Scene.RequestModuleInterface <IGridService>()
                .GetRegionByName(remoteClient.AllScopeIDs, regionName);

            if (regionInfo == null)
            {
                // can't find the region: Tell viewer and abort
                remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found.");
                return;
            }

            RequestTeleportLocation(remoteClient, regionInfo, position, lookat, teleportFlags);
        }
Ejemplo n.º 26
0
        public void RemoveExternalCaps(UUID agentID, GridRegion region)
        {
            OSDMap req = new OSDMap();
            req["AgentID"] = agentID;
            req["Region"] = region.ToOSD();
            req["Method"] = "RemoveCaps";

            foreach (string uri in m_servers)
                m_syncPoster.Post(uri, req);

            foreach (var h in GetHandlers(agentID, region.RegionID))
            {
                if (m_allowedCapsModules.Contains(h.Name))
                    h.IncomingCapsDestruction();
            }
        }
        /**
         * Object-related communications
         */

        public bool CreateObject(GridRegion destination, ISceneEntity sog)
        {
            if (Scene == null || destination == null)
            {
                return(false);
            }

            //MainConsole.Instance.Debug("[LOCAL COMMS]: Found region to SendCreateObject");
            IEntityTransferModule AgentTransferModule = Scene.RequestModuleInterface <IEntityTransferModule>();

            if (AgentTransferModule != null)
            {
                return(AgentTransferModule.IncomingCreateObject(Scene.RegionInfo.RegionID, sog));
            }

            return(false);
        }
Ejemplo n.º 28
0
        public void IncomingCapsRequest(UUID agentID, GridRegion region, ISimulationBase simbase, ref OSDMap capURLs)
        {
            m_syncMessage       = simbase.ApplicationRegistry.RequestModuleInterface <ISyncMessagePosterService>();
            m_appearanceService = simbase.ApplicationRegistry.RequestModuleInterface <IAgentAppearanceService>();
            m_region            = region;
            m_agentID           = agentID;

            if (m_appearanceService == null)
            {
                return;//Can't bake!
            }
            m_uri = "/CAPS/UpdateAvatarAppearance/" + UUID.Random() + "/";
            MainServer.Instance.AddStreamHandler(new GenericStreamHandler("POST",
                                                                          m_uri,
                                                                          UpdateAvatarAppearance));
            capURLs["UpdateAvatarAppearance"] = MainServer.Instance.ServerURI + m_uri;
        }
Ejemplo n.º 29
0
        private void FillOutHomeData(Framework.Services.UserInfo pinfo, GridRegion home)
        {
            int x = 1000 * Constants.RegionSize, y = 1000 * Constants.RegionSize;

            if (home != null)
            {
                x = home.RegionLocX;
                y = home.RegionLocY;
            }

            Home = string.Format(
                "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
                x,
                y,
                pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z,
                pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z);
        }
        public void Close(IScene scene)
        {
            //Deregister the interface
            scene.UnregisterModuleInterface<IGridRegisterModule>(this);
            m_scene = null;

            MainConsole.Instance.InfoFormat("[RegisterRegionWithGrid]: Deregistering region {0} from the grid...",
                                            scene.RegionInfo.RegionName);

            //Deregister from the grid server
            GridRegion r = new GridRegion(scene.RegionInfo);
            r.IsOnline = false;
            string error = "";
            if (scene.RegionInfo.HasBeenDeleted || !m_markRegionsAsOffline)
                scene.GridService.DeregisterRegion(r);
            else if ((error = scene.GridService.UpdateMap(r, false)) != "")
                MainConsole.Instance.WarnFormat(
                    "[RegisterRegionWithGrid]: Deregister from grid failed for region {0}, {1}",
                    scene.RegionInfo.RegionName, error);
        }
Ejemplo n.º 31
0
        protected AgentCircuitData LaunchAgentAtGrid(GridRegion destination, TeleportFlags tpFlags, UserAccount account,
            UUID session, UUID secureSession, Vector3 position,
            string currentWhere,
            IPEndPoint clientIP, List<UUID> friendsToInform, out string where, out string reason,
            out string seedCap, out GridRegion dest)
        {
            where = currentWhere;
            reason = string.Empty;
            uint circuitCode = 0;
            AgentCircuitData aCircuit = null;
            dest = destination;

            #region Launch Agent

            circuitCode = (uint) Util.RandomClass.Next();
            aCircuit = MakeAgent(destination, account, session, secureSession, circuitCode, position,
                                 clientIP);
            aCircuit.TeleportFlags = (uint) tpFlags;
            MainConsole.Instance.DebugFormat("[LoginService]: Attempting to log {0} into {1} at {2}...", account.Name, destination.RegionName, destination.ServerURI);
            LoginAgentArgs args = m_registry.RequestModuleInterface<IAgentProcessing>().
                                             LoginAgent(destination, aCircuit, friendsToInform);
            aCircuit.CachedUserInfo = args.CircuitData.CachedUserInfo;
            aCircuit.RegionUDPPort = args.CircuitData.RegionUDPPort;

            reason = args.Reason;
            reason = "";
            seedCap = args.SeedCap;
            bool success = args.Success;
            if (!success && m_GridService != null)
            {
                MainConsole.Instance.DebugFormat("[LoginService]: Failed to log {0} into {1} at {2}...", account.Name, destination.RegionName, destination.ServerURI);
                //Remove the landmark flag (landmark is used for ignoring the landing points in the region)
                aCircuit.TeleportFlags &= ~(uint) TeleportFlags.ViaLandmark;
                m_GridService.SetRegionUnsafe(destination.RegionID);

                // Make sure the client knows this isn't where they wanted to land
                where = "safe";

                // Try the default regions
                List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(account.AllScopeIDs);
                if (defaultRegions != null)
                {
                    success = TryFindGridRegionForAgentLogin(defaultRegions, account,
                                                             session, secureSession, circuitCode, position,
                                                             clientIP, aCircuit, friendsToInform,
                                                             out seedCap, out reason, out dest);
                }
                if (!success)
                {
                    // Try the fallback regions
                    List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.AllScopeIDs,
                                                                                  destination.RegionLocX,
                                                                                  destination.RegionLocY);
                    if (fallbacks != null)
                    {
                        success = TryFindGridRegionForAgentLogin(fallbacks, account,
                                                                 session, secureSession, circuitCode,
                                                                 position,
                                                                 clientIP, aCircuit, friendsToInform,
                                                                 out seedCap, out reason, out dest);
                    }
                    if (!success)
                    {
                        //Try to find any safe region
                        List<GridRegion> safeRegions = m_GridService.GetSafeRegions(account.AllScopeIDs,
                                                                                    destination.RegionLocX,
                                                                                    destination.RegionLocY);
                        if (safeRegions != null)
                        {
                            success = TryFindGridRegionForAgentLogin(safeRegions, account,
                                                                     session, secureSession, circuitCode,
                                                                     position, clientIP, aCircuit, friendsToInform,
                                                                     out seedCap, out reason, out dest);
                            if (!success)
                                reason = "No Region Found";
                        }
                    }
                }
            }

            #endregion

            if (success)
            {
                MainConsole.Instance.DebugFormat("[LoginService]: Successfully logged {0} into {1} at {2}...", account.Name, destination.RegionName, destination.ServerURI);
                //Set the region to safe since we got there
                m_GridService.SetRegionSafe(destination.RegionID);
                return aCircuit;
            }
            return null;
        }
        /// <summary>
        ///     Recursive SendGridInstantMessage over XMLRPC method.
        ///     This is called from within a dedicated thread.
        ///     The first time this is called, prevRegionHandle will be 0 Subsequent times this is called from
        ///     itself, prevRegionHandle will be the last region handle that we tried to send.
        ///     If the handles are the same, we look up the user's location using the grid.
        ///     If the handles are still the same, we end.  The send failed.
        /// </summary>
        /// <param name="im"></param>
        /// <param name="prevRegion">
        ///     Pass in 0 the first time this method is called.  It will be called recursively with the last
        ///     regionhandle tried
        /// </param>
        protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im,
                                                                    GridRegion prevRegion)
        {
            UUID toAgentID = im.ToAgentID;
            string HTTPPath = "";

            lock (IMUsersCache)
            {
                if (!IMUsersCache.TryGetValue(toAgentID, out HTTPPath))
                    HTTPPath = "";
            }

            if (HTTPPath != "")
            {
                //We've tried to send an IM to them before, pull out their info
                //Send the IM to their last location
                if (!doIMSending(HTTPPath, im))
                {
                    //If this fails, the user has either moved from their stored location or logged out
                    //Since it failed, let it look them up again and rerun
                    lock (IMUsersCache)
                    {
                        IMUsersCache.Remove(toAgentID);
                    }
                    //Clear the path and let it continue trying again.
                    HTTPPath = "";
                }
                else
                {
                    //Send the IM, and it made it to the user, return true
                    return;
                }
            }

            //Now query the grid server for the agent
            List<string> AgentLocations = m_agentInfoService.GetAgentsLocations(im.FromAgentID.ToString(),
                                                                 new List<string>(new[] {toAgentID.ToString()}));
            if (AgentLocations.Count > 0)
            {
                //No agents, so this user is offline
                if (AgentLocations[0] == "NotOnline")
                {
                    lock (IMUsersCache)
                    {
                        //Remove them so we keep testing against the db
                        IMUsersCache.Remove(toAgentID);
                    }
                    MainConsole.Instance.Info("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
                    HandleUndeliveredMessage(im, "User is not set as online by presence service.");
                    return;
                }
                if (AgentLocations[0] == "NonExistant")
                {
                    IMUsersCache.Remove(toAgentID);
                    MainConsole.Instance.Info("[GRID INSTANT MESSAGE]: Unable to deliver an instant message to " +
                                              toAgentID +
                                              ", user does not exist");
                    HandleUndeliveredMessage(im, "User does not exist.");
                    return;
                }
                HTTPPath = AgentLocations[0];
            }

            //We found the agent's location, now ask them about the user
            if (HTTPPath != "")
            {
                if (!doIMSending(HTTPPath, im))
                {
                    //It failed, stop now
                    lock (IMUsersCache)
                    {
                        //Remove them so we keep testing against the db
                        IMUsersCache.Remove(toAgentID);
                    }
                    MainConsole.Instance.Info(
                        "[GRID INSTANT MESSAGE]: Unable to deliver an instant message as the region could not be found");
                    HandleUndeliveredMessage(im, "Failed to send IM to destination.");
                    return;
                }
                else
                {
                    //Add to the cache
                    if (!IMUsersCache.ContainsKey(toAgentID))
                        IMUsersCache.Add(toAgentID, HTTPPath);
                    //Send the IM, and it made it to the user, return true
                    return;
                }
            }
            else
            {
                //Couldn't find them, stop for now
                lock (IMUsersCache)
                {
                    //Remove them so we keep testing against the db
                    IMUsersCache.Remove(toAgentID);
                }
                MainConsole.Instance.Info(
                    "[GRID INSTANT MESSAGE]: Unable to deliver an instant message as the region could not be found");
                HandleUndeliveredMessage(im, "Agent Location was blank.");
            }
        }
Ejemplo n.º 33
0
 protected MapBlockData MapBlockFromGridRegion(GridRegion r, int flag)
 {
     MapBlockData block = new MapBlockData();
     if (r == null)
     {
         block.Access = (byte) SimAccess.Down;
         block.MapImageID = UUID.Zero;
         return block;
     }
     block.Access = r.Access;
     if ((flag & 0xffff) == 0)
         block.MapImageID = r.TerrainImage;
     if ((flag & 0xffff) == 1)
         block.MapImageID = r.TerrainMapImage;
     if ((flag & 0xffff) == 2)
         block.MapImageID = r.ParcelMapImage;
     block.Name = r.RegionName;
     block.X = (ushort) (r.RegionLocX/Constants.RegionSize);
     block.Y = (ushort) (r.RegionLocY/Constants.RegionSize);
     block.SizeX = (ushort) (r.RegionSizeX);
     block.SizeY = (ushort) (r.RegionSizeY);
     return block;
 }
 private void FillOutRegionData(AgentCircuitData circuitData, GridRegion destination)
 {
     IPEndPoint endPoint = destination.ExternalEndPoint;
     //We don't need this anymore, we set this from what we get from the region
     //endPoint = Util.ResolveAddressForClient (endPoint, circuitData.ClientIPEndPoint);
     SimAddress = endPoint.Address.ToString();
     SimPort = (uint) circuitData.RegionUDPPort;
     RegionX = (uint) destination.RegionLocX;
     RegionY = (uint) destination.RegionLocY;
     RegionSizeX = destination.RegionSizeX;
     RegionSizeY = destination.RegionSizeY;
 }
        /// <summary>
        ///     This turns a root agent into a child agent
        ///     when an agent departs this region for a neighbor, this gets called.
        ///     It doesn't get called for a teleport.  Reason being, an agent that
        ///     teleports out may not end up anywhere near this region
        /// </summary>
        public virtual void MakeChildAgent(GridRegion destination)
        {
            IsChildAgent = true;
            SuccessfullyMadeRootAgent = false;
            SuccessfulTransit();
            // It looks like m_animator is set to null somewhere, and MakeChild
            // is called after that. Probably in aborted teleports.
            if (m_animator == null)
                m_animator = new Animator(this);
            else
                Animator.ResetAnimations();

            MainConsole.Instance.DebugFormat(
                "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
                Name, UUID, m_scene.RegionInfo.RegionName);

            RemoveFromPhysicalScene();
            m_sceneViewer.Reset();

            SendScriptEventToAllAttachments(Changed.TELEPORT);
            m_scene.EventManager.TriggerOnMakeChildAgent(this, destination);

            Reset();
        }
Ejemplo n.º 36
0
        protected GridRegion FindDestination(UserAccount account, UserInfo pinfo, UUID sessionID, string startLocation,
            GridRegion home, out TeleportFlags tpFlags, out string where,
            out Vector3 position, out Vector3 lookAt)
        {
            where = "home";
            position = new Vector3(128, 128, 25);
            lookAt = new Vector3(0, 1, 0);
            tpFlags = TeleportFlags.ViaLogin;

            if (m_GridService == null)
                return null;

            if (startLocation.Equals("home"))
            {
                tpFlags |= TeleportFlags.ViaLandmark;
                // logging into home region
                if (pinfo == null)
                    return null;

                GridRegion region = null;

                bool tryDefaults = false;

                if (home == null)
                {
                    MainConsole.Instance.WarnFormat(
                        "[LLOGIN SERVICE]: User {0} {1} tried to login to a 'home' start location but they have none set",
                        account.FirstName, account.LastName);

                    tryDefaults = true;
                }
                else
                {
                    region = home;

                    position = pinfo.HomePosition;
                    lookAt = pinfo.HomeLookAt;
                }

                if (tryDefaults)
                {
                    tpFlags &= ~TeleportFlags.ViaLandmark;
                    List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.AllScopeIDs);
                    if (defaults != null && defaults.Count > 0)
                    {
                        region = defaults[0];
                        where = "safe";
                    }
                    else
                    {
                        List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.AllScopeIDs, 0, 0);
                        if (fallbacks != null && fallbacks.Count > 0)
                        {
                            region = fallbacks[0];
                            where = "safe";
                        }
                        else
                        {
                            //Try to find any safe region
                            List<GridRegion> safeRegions = m_GridService.GetSafeRegions(account.AllScopeIDs, 0, 0);
                            if (safeRegions != null && safeRegions.Count > 0)
                            {
                                region = safeRegions[0];
                                where = "safe";
                            }
                            else
                            {
                                MainConsole.Instance.WarnFormat(
                                    "[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region",
                                    account.FirstName, account.LastName);
                                defaults = m_GridService.GetRegionsByName(account.AllScopeIDs, "", 0, 1);
                                if (defaults != null && defaults.Count > 0)
                                {
                                    region = defaults[0];
                                    where = "safe";
                                }
                            }
                        }
                    }
                }

                return region;
            }
            if (startLocation.Equals("last"))
            {
                tpFlags |= TeleportFlags.ViaLandmark;
                // logging into last visited region
                where = "last";

                if (pinfo == null)
                    return null;

                GridRegion region = null;

                if (pinfo.CurrentRegionID.Equals(UUID.Zero) ||
                    (region = m_GridService.GetRegionByUUID(account.AllScopeIDs, pinfo.CurrentRegionID)) == null)
                {
                    tpFlags &= ~TeleportFlags.ViaLandmark;
                    List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.AllScopeIDs);
                    if (defaults != null && defaults.Count > 0)
                    {
                        region = defaults[0];
                        where = "safe";
                    }
                    else
                    {
                        defaults = m_GridService.GetFallbackRegions(account.AllScopeIDs, 0, 0);
                        if (defaults != null && defaults.Count > 0)
                        {
                            region = defaults[0];
                            where = "safe";
                        }
                        else
                        {
                            defaults = m_GridService.GetSafeRegions(account.AllScopeIDs, 0, 0);
                            if (defaults != null && defaults.Count > 0)
                            {
                                region = defaults[0];
                                where = "safe";
                            }
                        }
                    }
                }
                else
                {
                    position = pinfo.CurrentPosition;
                    if (position.X < 0)
                        position.X = 0;
                    if (position.Y < 0)
                        position.Y = 0;
                    if (position.Z < 0)
                        position.Z = 0;
                    if (position.X > region.RegionSizeX)
                        position.X = region.RegionSizeX;
                    if (position.Y > region.RegionSizeY)
                        position.Y = region.RegionSizeY;

                    lookAt = pinfo.CurrentLookAt;
                }

                return region;
            }
            else
            {
                // free uri form
                // e.g. New Moon&135&46  New [email protected]:8002&153&34
                where = "url";
                Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
                Match uriMatch = reURI.Match(startLocation);
                position = new Vector3(float.Parse(uriMatch.Groups["x"].Value, Culture.NumberFormatInfo),
                                       float.Parse(uriMatch.Groups["y"].Value, Culture.NumberFormatInfo),
                                       float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo));

                string regionName = uriMatch.Groups["region"].ToString();
                if (!regionName.Contains("@"))
                {
                    List<GridRegion> regions = m_GridService.GetRegionsByName(account.AllScopeIDs, regionName, 0, 1);
                    if ((regions == null) || (regions.Count == 0))
                    {
                        MainConsole.Instance.InfoFormat(
                            "[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.",
                            startLocation, regionName);
                        regions = m_GridService.GetDefaultRegions(account.AllScopeIDs);
                        if (regions != null && regions.Count > 0)
                        {
                            where = "safe";
                            return regions[0];
                        }
                        List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.AllScopeIDs, 0, 0);
                        if (fallbacks != null && fallbacks.Count > 0)
                        {
                            where = "safe";
                            return fallbacks[0];
                        }
                        //Try to find any safe region
                        List<GridRegion> safeRegions = m_GridService.GetSafeRegions(account.AllScopeIDs, 0, 0);
                        if (safeRegions != null && safeRegions.Count > 0)
                        {
                            where = "safe";
                            return safeRegions[0];
                        }
                        MainConsole.Instance.InfoFormat(
                            "[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not have any available regions.",
                            startLocation);
                        return null;
                    }
                    return regions[0];
                }
                //This is so that you can login to other grids via IWC (or HG), example"[email protected]:8002". All this really needs to do is inform the other grid that we have a user who wants to connect. IWC allows users to login by default to other regions (without the host names), but if one is provided and we don't have a link, we need to create one here.
                string[] parts = regionName.Split(new char[] {'@'});
                if (parts.Length < 2)
                {
                    MainConsole.Instance.InfoFormat(
                        "[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}",
                        startLocation, regionName);
                    return null;
                }
                // Valid specification of a remote grid

                regionName = parts[0];
                //Try now that we removed the domain locator
                GridRegion region = m_GridService.GetRegionByName(account.AllScopeIDs, regionName);
                if (region != null && region.RegionName == regionName)
                    //Make sure the region name is right too... it could just be a similar name
                    return region;

                List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.AllScopeIDs);
                if (defaults != null && defaults.Count > 0)
                {
                    where = "safe";
                    return defaults[0];
                }
                else
                {
                    List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.AllScopeIDs, 0, 0);
                    if (fallbacks != null && fallbacks.Count > 0)
                    {
                        where = "safe";
                        return fallbacks[0];
                    }
                    else
                    {
                        //Try to find any safe region
                        List<GridRegion> safeRegions = m_GridService.GetSafeRegions(account.AllScopeIDs, 0, 0);
                        if (safeRegions != null && safeRegions.Count > 0)
                        {
                            where = "safe";
                            return safeRegions[0];
                        }
                        MainConsole.Instance.InfoFormat(
                            "[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not have any available regions.",
                            startLocation);
                        return null;
                    }
                }
            }
        }
        public bool RetrieveAgent(GridRegion destination, UUID agentID, bool agentIsLeaving, out AgentData agentData,
            out AgentCircuitData circuitData)
        {
            agentData = null;
            circuitData = null;

            IScene Scene = destination == null ? null : GetScene(destination.RegionID);
            if (Scene == null || destination == null)
                return false;

            //MainConsole.Instance.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
            IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
            if (transferModule != null)
                return transferModule.IncomingRetrieveRootAgent(Scene, agentID, agentIsLeaving, out agentData,
                                                                out circuitData);
            return false;
            //MainConsole.Instance.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate");
        }
        public bool MakeChildAgent(UUID AgentID, GridRegion oldRegion, GridRegion destination, bool isCrossing)
        {
            IScene Scene = oldRegion == null ? null : GetScene(oldRegion.RegionID);
            if (Scene == null)
                return false;

            IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
            if (transferModule == null) return false;
            transferModule.MakeChildAgent(Scene.GetScenePresence(AgentID), destination, isCrossing);
            return true;
        }
        public bool FailedToTeleportAgent(GridRegion destination, UUID failedRegionID, UUID agentID, string reason,
            bool isCrossing)
        {
            IScene Scene = destination == null ? null : GetScene(destination.RegionID);
            if (Scene == null)
                return false;

            IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
            if (transferModule == null) return false;
            transferModule.FailedToTeleportAgent(destination, agentID, reason, isCrossing);
            return true;
        }
        /**
         * Object-related communications
         */
        public bool CreateObject(GridRegion destination, ISceneEntity sog)
        {
            IScene Scene = destination == null ? null : GetScene(destination.RegionID);
            if (Scene == null || destination == null)
                return false;

            //MainConsole.Instance.Debug("[LOCAL COMMS]: Found region to SendCreateObject");
            IEntityTransferModule AgentTransferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
            if (AgentTransferModule != null)
                return AgentTransferModule.IncomingCreateObject(Scene.RegionInfo.RegionID, sog);

            return false;
        }
        public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, Framework.Services.UserInfo pinfo,
                               GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList,
                               IInventoryService invService, ILibraryService libService,
                               string where, string startlocation, Vector3 position, Vector3 lookAt,
                               List<InventoryItemBase> gestures,
                               GridRegion home, IPEndPoint clientIP, string AdultMax, string AdultRating,
                               ArrayList eventValues, ArrayList eventNotificationValues, ArrayList classifiedValues,
                               string seedCap, IConfigSource source,
                               string DisplayName, string cofversion, IGridInfo info)
            : this()
        {
            m_source = source;
            m_gridInfo = info;
            SeedCapability = seedCap;

            FillOutInventoryData(invSkel, libService, invService);

            FillOutActiveGestures(gestures);

            CircuitCode = (int) aCircuit.CircuitCode;
            Lastname = account.LastName;
            Firstname = account.FirstName;
            this.DisplayName = DisplayName;
            AgentID = account.PrincipalID;
            SessionID = aCircuit.SessionID;
            SecureSessionID = aCircuit.SecureSessionID;
            BuddList = ConvertFriendListItem(friendsList);
            StartLocation = where;
            AgentAccessMax = AdultMax;
            AgentAccess = AdultRating;
            eventCategories = eventValues;
            eventNotifications = eventNotificationValues;
            classifiedCategories = classifiedValues;
            COFVersion = cofversion;

            FillOutHomeData(pinfo, home);
            LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z);

            FillOutRegionData(aCircuit, destination);
            login = "******";
            ErrorMessage = "";
            ErrorReason = LoginResponseEnum.OK;
        }
        private void FillOutHomeData(Framework.Services.UserInfo pinfo, GridRegion home)
        {
            int x = 1000*Constants.RegionSize, y = 1000*Constants.RegionSize;
            if (home != null)
            {
                x = home.RegionLocX;
                y = home.RegionLocY;
            }

            Home = string.Format(
                "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
                x,
                y,
                pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z,
                pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z);
        }
Ejemplo n.º 43
0
 protected AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
     UUID session, UUID secureSession, uint circuit,
     Vector3 position, IPEndPoint clientIP)
 {
     return new AgentCircuitData
                                     {
                                         AgentID = account.PrincipalID,
                                         IsChildAgent = false,
                                         CircuitCode = circuit,
                                         SecureSessionID = secureSession,
                                         SessionID = session,
                                         StartingPosition = position,
                                         IPAddress = clientIP.Address.ToString()
                                     };
 }
        public bool UpdateAgent(GridRegion destination, AgentData agentData)
        {
            IScene Scene = destination == null ? null : GetScene(destination.RegionID);
            if (destination == null || Scene == null || agentData == null)
                return false;

            bool retVal = false;
            IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
            if (transferModule != null)
                retVal = transferModule.IncomingChildAgentDataUpdate(Scene, agentData);

            //            MainConsole.Instance.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle);
            return retVal;
        }
Ejemplo n.º 45
0
 protected bool TryFindGridRegionForAgentLogin(List<GridRegion> regions, UserAccount account,
     UUID session, UUID secureSession,
     uint circuitCode, Vector3 position,
     IPEndPoint clientIP, AgentCircuitData aCircuit, List<UUID> friendsToInform,
     out string seedCap, out string reason, out GridRegion destination)
 {
     LoginAgentArgs args = null;
     foreach (GridRegion r in regions)
     {
         if (r == null)
             continue;
         MainConsole.Instance.DebugFormat("[LoginService]: Attempting to log {0} into {1} at {2}...", account.Name, r.RegionName, r.ServerURI);
         args = m_registry.RequestModuleInterface<IAgentProcessing>().
                           LoginAgent(r, aCircuit, friendsToInform);
         if (args.Success)
         {
             aCircuit = MakeAgent(r, account, session, secureSession, circuitCode, position, clientIP);
             destination = r;
             reason = args.Reason;
             seedCap = args.SeedCap;
             return true;
         }
         m_GridService.SetRegionUnsafe(r.RegionID);
     }
     if (args != null)
     {
         seedCap = args.SeedCap;
         reason = args.Reason;
     }
     else
     {
         seedCap = "";
         reason = "";
     }
     destination = null;
     return false;
 }
        public bool UpdateAgent(GridRegion destination, AgentPosition agentData)
        {
            IScene Scene = destination == null ? null : GetScene(destination.RegionID);
            if (Scene == null || destination == null)
                return false;

            //MainConsole.Instance.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
            IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
            if (transferModule != null)
                return transferModule.IncomingChildAgentDataUpdate(Scene, agentData);

            return false;
        }
 public void FailedCrossingTransit(GridRegion failedCrossingRegion)
 {
     m_inTransit = false;
     m_failedNeighborCrossing[failedCrossingRegion.RegionID] = Util.EnvironmentTickCount();
 }
Ejemplo n.º 48
0
 protected bool TryFindGridRegionForAgentLogin(List<GridRegion> regions, UserAccount account,
     UUID session, UUID secureSession,
     uint circuitCode, Vector3 position,
     IPEndPoint clientIP, AgentCircuitData aCircuit, out string seedCap,
     out string reason, out GridRegion destination)
 {
     LoginAgentArgs args = null;
     foreach (GridRegion r in regions)
     {
         args = m_registry.RequestModuleInterface<IAgentProcessing>().
                           LoginAgent(r, aCircuit);
         if (args.Success)
         {
             aCircuit = MakeAgent(r, account, session, secureSession, circuitCode, position, clientIP);
             destination = r;
             reason = args.Reason;
             seedCap = args.SeedCap;
             return true;
         }
         m_GridService.SetRegionUnsafe(r.RegionID);
     }
     if (args != null)
     {
         seedCap = args.SeedCap;
         reason = args.Reason;
     }
     else
     {
         seedCap = "";
         reason = "";
     }
     destination = null;
     return false;
 }
 public virtual void SetAgentLeaving(GridRegion destindation)
 {
     m_scene.EventManager.TriggerOnSetAgentLeaving(this, destindation);
 }
 public void SuccessfulCrossingTransit(GridRegion crossingRegion)
 {
     m_inTransit = false;
     //We got there fine, remove it
     m_failedNeighborCrossing.Remove(crossingRegion.RegionID);
 }
Ejemplo n.º 51
0
        private void ClientOnParcelInfoRequest(IClientAPI remoteClient, UUID parcelID)
        {
            if (parcelID == UUID.Zero)
                return;
            ulong RegionHandle = 0;
            uint X, Y, Z;
            Util.ParseFakeParcelID(parcelID, out RegionHandle,
                                   out X, out Y, out Z);
            MainConsole.Instance.DebugFormat("[LAND] got parcelinfo request for regionHandle {0}, x/y {1}/{2}",
                                             RegionHandle, X, Y);
            IDirectoryServiceConnector DSC = Framework.Utilities.DataManager.RequestPlugin<IDirectoryServiceConnector>();
            if (DSC != null)
            {
                LandData data = DSC.GetParcelInfo(parcelID);

                if (data != null) // if we found some data, send it
                {
                    GridRegion info;
                    int RegionX, RegionY;
                    Util.UlongToInts(RegionHandle, out RegionX, out RegionY);
                    RegionX = (int) ((float) RegionX/Constants.RegionSize)*Constants.RegionSize;
                    RegionY = (RegionY/Constants.RegionSize)*Constants.RegionSize;
                    if (RegionX == m_scene.RegionInfo.RegionLocX &&
                        RegionY == m_scene.RegionInfo.RegionLocY)
                    {
                        info = new GridRegion(m_scene.RegionInfo);
                    }
                    else
                    {
                        // most likely still cached from building the extLandData entry
                        info = m_scene.GridService.GetRegionByPosition(null, RegionX, RegionY);
                    }
                    if (info == null)
                    {
                        MainConsole.Instance.WarnFormat("[LAND]: Failed to find region having parcel {0} @ {1} {2}",
                                                        parcelID, X, Y);
                        return;
                    }
                    // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
                    MainConsole.Instance.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...",
                                                     data.Name, RegionHandle);
                    remoteClient.SendParcelInfo(data, parcelID, (uint) (info.RegionLocX + data.UserLocation.X),
                                                (uint) (info.RegionLocY + data.UserLocation.Y), info.RegionName);
                }
                else
                    MainConsole.Instance.WarnFormat("[LAND]: Failed to find parcel {0}", parcelID);
            }
            else
                MainConsole.Instance.Debug("[LAND] got no directory service; not sending");
        }
Ejemplo n.º 52
0
 OSDMap service_OnMessageReceived(OSDMap message)
 {
     string method = message["Method"];
     if (method != "GetCaps" && method != "RemoveCaps")
         return null;
     UUID AgentID = message["AgentID"];
     GridRegion region = new GridRegion();
     region.FromOSD((OSDMap)message["Region"]);
     OSDMap map = new OSDMap();
     switch (method)
     {
         case "GetCaps":
             foreach (var h in GetHandlers(AgentID, region.RegionID))
             {
                 if (m_allowedCapsModules.Contains(h.Name))
                     h.IncomingCapsRequest(AgentID, region, m_registry.RequestModuleInterface<ISimulationBase>(), ref map);
             }
             return map;
         case "RemoveCaps":
             foreach (var h in GetHandlers(AgentID, region.RegionID))
             {
                 if (m_allowedCapsModules.Contains(h.Name))
                     h.IncomingCapsDestruction();
             }
             return map;
     }
     return null;
 }