Пример #1
0
        /// <summary>
        /// Asynchronous call to information neighbouring regions that this region is up
        /// </summary>
        /// <param name="region"></param>
        /// <param name="regionhandle"></param>
        private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
        {
            uint x = 0, y = 0;
            Utils.LongToUInts(regionhandle, out x, out y);

            GridRegion neighbour = null;
            if (neighbourService != null)
                neighbour = neighbourService.HelloNeighbour(regionhandle, region);
            else
                m_log.DebugFormat( "{0} neighbour service provided for region {0} to inform neigbhours of status", LogHeader, m_scene.Name);

            if (neighbour != null)
            {
                m_log.DebugFormat( "{0} Region {1} successfully informed neighbour {2} at {3}-{4} that it is up",
                    LogHeader, m_scene.Name, neighbour.RegionName, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));

                m_scene.EventManager.TriggerOnRegionUp(neighbour);
            }
            else
            {
                m_log.WarnFormat(
                    "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.",
                    m_scene.Name, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
            }
        }
        /// <summary>
        /// Asynchronous call to information neighbouring regions that this region is up
        /// </summary>
        /// <param name="region"></param>
        /// <param name="regionhandle"></param>
        private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
        {
            uint x = 0, y = 0;
            Utils.LongToUInts(regionhandle, out x, out y);

            GridRegion neighbour = null;
            if (neighbourService != null)
                neighbour = neighbourService.HelloNeighbour(regionhandle, region);
            else
                m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region");

            if (neighbour != null)
            {
                m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
                m_scene.EventManager.TriggerOnRegionUp(neighbour);
            }
            else
            {
                if (m_scene.GridService != null)
                {
                    neighbour = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
                    
                    if (neighbour != null)
                        m_log.InfoFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Asynchronous call to information neighbouring regions that this region is up
        /// </summary>
        /// <param name="region"></param>
        /// <param name="regionhandle"></param>
        private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
        {
            uint x = 0, y = 0;

            Utils.LongToUInts(regionhandle, out x, out y);

            GridRegion neighbour = null;

            if (neighbourService != null)
            {
                neighbour = neighbourService.HelloNeighbour(regionhandle, region);
            }
            else
            {
                m_log.DebugFormat(
                    "[SCENE COMMUNICATION SERVICE]: No neighbour service provided for region {0} to inform neigbhours of status",
                    m_scene.Name);
            }

            if (neighbour != null)
            {
                m_log.DebugFormat(
                    "[SCENE COMMUNICATION SERVICE]: Region {0} successfully informed neighbour {1} at {2}-{3} that it is up",
                    m_scene.Name, neighbour.RegionName, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));

                m_scene.EventManager.TriggerOnRegionUp(neighbour);
            }
            else
            {
                m_log.WarnFormat(
                    "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.",
                    m_scene.Name, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
            }
        }
        /// <summary>
        /// Asynchronous call to information neighbouring regions that this region is up
        /// </summary>
        /// <param name="region"></param>
        /// <param name="regionhandle"></param>
        private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
        {
            uint x = 0, y = 0;

            Utils.LongToUInts(regionhandle, out x, out y);

            GridRegion neighbour = null;

            if (neighbourService != null)
            {
                neighbour = neighbourService.HelloNeighbour(regionhandle, region);
            }
            else
            {
                m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region");
            }

            if (neighbour != null)
            {
                m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
                m_scene.EventManager.TriggerOnRegionUp(neighbour);
            }
            else
            {
                m_log.InfoFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
            }
        }
Пример #5
0
        public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
        {
            //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
            if (neighbourService == null)
            {
                m_log.ErrorFormat("{0} No neighbour service provided for region {1} to inform neigbhours of status", LogHeader, m_scene.Name);
                return;
            }

            List <GridRegion> neighbours
                = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID);

            List <ulong> onlineNeighbours = new List <ulong>();

            foreach (GridRegion n in neighbours)
            {
                //m_log.DebugFormat(
                //   "{0}: Region flags for {1} as seen by {2} are {3}",
                //    LogHeader, n.RegionName, m_scene.Name, regionFlags != null ? regionFlags.ToString() : "not present");

                // Robust services before 2015-01-14 do not return the regionFlags information.  In this case, we could
                // make a separate RegionFlags call but this would involve a network call for each neighbour.
                if (n.RegionFlags != null)
                {
                    if ((n.RegionFlags & OpenSim.Framework.RegionFlags.RegionOnline) != 0)
                    {
                        onlineNeighbours.Add(n.RegionHandle);
                    }
                }
                else
                {
                    onlineNeighbours.Add(n.RegionHandle);
                }
            }

            if (onlineNeighbours.Count > 0)
            {
                Util.FireAndForget(o =>
                {
                    foreach (ulong regionhandle in onlineNeighbours)
                    {
                        Util.RegionHandleToRegionLoc(regionhandle, out uint rx, out uint ry);
                        GridRegion neighbour = neighbourService.HelloNeighbour(regionhandle, region);
                        if (neighbour != null)
                        {
                            m_log.DebugFormat("{0} Region {1} successfully informed neighbour {2} at {3}-{4} that it is up",
                                              LogHeader, m_scene.Name, neighbour.RegionName, rx, ry);

                            m_scene.EventManager.TriggerOnRegionUp(neighbour);
                        }
                        else
                        {
                            m_log.WarnFormat("{0} Region {1} failed to inform neighbour at {2}-{3} that it is up.",
                                             LogHeader, m_scene.Name, rx, ry);
                        }
                    }
                });
            }
        }
        public override byte[] Handle(string path, Stream request,
                                      IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            byte[] result = new byte[0];

            UUID   regionID;
            string action;
            ulong  regionHandle;

            if (RestHandlerUtils.GetParams(path, out regionID, out regionHandle, out action))
            {
                m_log.InfoFormat("[RegionPostHandler]: Invalid parameters for neighbour message {0}", path);
                httpResponse.StatusCode        = (int)HttpStatusCode.BadRequest;
                httpResponse.StatusDescription = "Invalid parameters for neighbour message " + path;

                return(result);
            }

            if (m_AuthenticationService != null)
            {
                // Authentication
                string authority = string.Empty;
                string authToken = string.Empty;
                if (!RestHandlerUtils.GetAuthentication(httpRequest, out authority, out authToken))
                {
                    m_log.InfoFormat("[RegionPostHandler]: Authentication failed for neighbour message {0}", path);
                    httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized;
                    return(result);
                }
                // TODO: Rethink this
                //if (!m_AuthenticationService.VerifyKey(regionID, authToken))
                //{
                //    m_log.InfoFormat("[RegionPostHandler]: Authentication failed for neighbour message {0}", path);
                //    httpResponse.StatusCode = (int)HttpStatusCode.Forbidden;
                //    return result;
                //}
                m_log.DebugFormat("[RegionPostHandler]: Authentication succeeded for {0}", regionID);
            }

            OSDMap args = Util.GetOSDMap(request, (int)httpRequest.ContentLength);

            if (args == null)
            {
                httpResponse.StatusCode        = (int)HttpStatusCode.BadRequest;
                httpResponse.StatusDescription = "Unable to retrieve data";
                m_log.DebugFormat("[RegionPostHandler]: Unable to retrieve data for post {0}", path);
                return(result);
            }

            // retrieve the regionhandle
            ulong regionhandle = 0;

            if (args["destination_handle"] != null)
            {
                UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
            }

            RegionInfo aRegion = new RegionInfo();

            try
            {
                aRegion.UnpackRegionInfoData(args);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[RegionPostHandler]: exception on unpacking region info {0}", ex.Message);
                httpResponse.StatusCode        = (int)HttpStatusCode.BadRequest;
                httpResponse.StatusDescription = "Problems with data deserialization";
                return(result);
            }

            // Finally!
            GridRegion thisRegion = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);

            OSDMap resp = new OSDMap(1);

            if (thisRegion != null)
            {
                resp["success"] = OSD.FromBoolean(true);
            }
            else
            {
                resp["success"] = OSD.FromBoolean(false);
            }

            httpResponse.StatusCode = (int)HttpStatusCode.OK;

            return(Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp)));
        }
        /// <summary>
        /// Asynchronous call to information neighbouring regions that this region is up
        /// </summary>
        /// <param name="region"></param>
        /// <param name="regionhandle"></param>
        private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
        {
            m_log.Info("[INTERGRID]: Starting to inform neighbors that I'm here");
            //RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port);

            //bool regionAccepted =
            //    m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region), regionhandle);

            //bool regionAccepted = m_interregionCommsOut.SendHelloNeighbour(regionhandle, region);
            bool regionAccepted = false;
            if (neighbourService != null)
                regionAccepted = neighbourService.HelloNeighbour(regionhandle, region);
            else
                m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region");

            if (regionAccepted)
            {
                m_log.Info("[INTERGRID]: Completed informing neighbors that I'm here");
                handlerRegionUp = OnRegionUp;

                // yes, we're notifying ourselves.
                if (handlerRegionUp != null)
                    handlerRegionUp(region);
            }
            else
            {
                m_log.Warn("[INTERGRID]: Failed to inform neighbors that I'm here.");
            }
        }
Пример #8
0
        // TODO: unused: private bool m_AllowForeignGuests;
        protected void ProcessPostRequest(OSDMap args, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID regionID)
        {
            byte[] result = new byte[0];

            if (m_AuthenticationService != null)
            {
                // Authentication
                string authority = string.Empty;
                string authToken = string.Empty;
                if (!RestHandlerUtils.GetAuthentication(httpRequest, out authority, out authToken))
                {
                    m_log.InfoFormat("[RegionPostHandler]: Authentication failed for neighbour message");
                    httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized;
                    return;
                }
                // TODO: Rethink this
                //if (!m_AuthenticationService.VerifyKey(regionID, authToken))
                //{
                //    m_log.InfoFormat("[RegionPostHandler]: Authentication failed for neighbour message {0}", path);
                //    httpResponse.StatusCode = (int)HttpStatusCode.Forbidden;
                //    return result;
                //}
                m_log.DebugFormat("[RegionPostHandler]: Authentication succeeded for {0}", regionID);
            }

            // retrieve the regionhandle
            ulong regionhandle = 0;

            if (args["destination_handle"] != null)
            {
                UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
            }

            RegionInfo aRegion = new RegionInfo();

            try
            {
                aRegion.UnpackRegionInfoData(args);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[RegionPostHandler]: exception on unpacking region info {0}", ex.Message);
                httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
                return;
            }

            // Finally!
            GridRegion thisRegion = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);

            OSDMap resp = new OSDMap(1);

            if (thisRegion != null)
            {
                resp["success"] = OSD.FromBoolean(true);
            }
            else
            {
                resp["success"] = OSD.FromBoolean(false);
            }

            httpResponse.RawBuffer  = Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp));
            httpResponse.StatusCode = (int)HttpStatusCode.OK;
        }