当前位置: 首页>>代码示例>>C#>>正文


C# RegionInfo.UnpackRegionInfoData方法代码示例

本文整理汇总了C#中OpenSim.Framework.RegionInfo.UnpackRegionInfoData方法的典型用法代码示例。如果您正苦于以下问题:C# RegionInfo.UnpackRegionInfoData方法的具体用法?C# RegionInfo.UnpackRegionInfoData怎么用?C# RegionInfo.UnpackRegionInfoData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSim.Framework.RegionInfo的用法示例。


在下文中一共展示了RegionInfo.UnpackRegionInfoData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Handle

        public override byte[] Handle(string path, Stream request,
                OSHttpRequest httpRequest, OSHttpResponse 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));
        }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:79,代码来源:NeighbourHandlers.cs

示例2: UnpackMessageAndCallHandler

        /// <summary>
        /// Unpacks the message sent from a neighboring region and calls the given handler
        /// </summary>
        /// <param name="request"></param>
        /// <param name="httpResponse"></param>
        /// <param name="handler"></param>
        /// <returns></returns>
        private string UnpackMessageAndCallHandler(Stream request, OSHttpResponse httpResponse, Action<SimpleRegionInfo> handler)
        {
            try
            {
                byte[] binaryLLSD;
                using (MemoryStream ms = new MemoryStream())
                {
                    request.CopyTo(ms);
                    binaryLLSD = ms.ToArray();
                }

                OSDMap regionInfoPackage = (OSDMap)OSDParser.DeserializeLLSDBinary(binaryLLSD);
                RegionInfo regionInfo = new RegionInfo();
                regionInfo.UnpackRegionInfoData(regionInfoPackage);

                handler(regionInfo);

                httpResponse.StatusCode = 200;
                return "OK";
            }
            catch (Exception e)
            {
                httpResponse.StatusCode = 500;
                return "OnHeartbeatReceived: Error: " + e.ToString();
            }
        }
开发者ID:kf6kjg,项目名称:halcyon,代码行数:33,代码来源:SurroundingRegionManager.cs

示例3: InformNeighborsOfChatMessage

        private byte[] InformNeighborsOfChatMessage(Dictionary<string, object> request)
        {
            byte[] result = new byte[0];

            if (!CheckThreatLevel(NeighborThreatLevel.Low))
            {
                return result;
            }

            // retrieve the region
            RegionInfo aRegion = new RegionInfo();
            try
            {
                aRegion.UnpackRegionInfoData(Util.DictionaryToOSD(request));
            }
            catch (Exception)
            {
                return result;
            }

            OSChatMessage message = new OSChatMessage();
            message.FromKVP(WebUtils.ParseQueryString(request["MESSAGE"].ToString()));
            ChatSourceType type = (ChatSourceType)int.Parse(request["TYPE"].ToString());
            if (m_AuthenticationService != null)
            {
                //Set password on the incoming region
                if (m_AuthenticationService.CheckExists(aRegion.RegionID))
                {
                    if (m_AuthenticationService.Authenticate(aRegion.RegionID, aRegion.Password.ToString(), 100) == "")
                    {
                        m_log.Warn("[RegionPostHandler]: Authentication failed for region " + aRegion.RegionName);
                        return result;
                    }
                    else
                        m_log.InfoFormat("[RegionPostHandler]: Authentication succeeded for {0}", aRegion.RegionName);
                }
                else //Set the password then
                    m_AuthenticationService.SetPasswordHashed(aRegion.RegionID, aRegion.Password.ToString());
            }

            // Finally!
            m_NeighborService.SendChatMessageToNeighbors(message, type, aRegion);

            Dictionary<string, object> resp = new Dictionary<string, object>();
            resp["success"] = "true";

            string xmlString = WebUtils.BuildXmlResponse(resp);
            UTF8Encoding encoding = new UTF8Encoding();
            return encoding.GetBytes(xmlString);
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:50,代码来源:NeighbourHandlers.cs

示例4: InformNeighborsRegionIsDown

        private byte[] InformNeighborsRegionIsDown(Dictionary<string, object> request)
        {
            byte[] result = new byte[0];

            // retrieve the region
            RegionInfo aRegion = new RegionInfo();
            try
            {
                aRegion.UnpackRegionInfoData(Util.DictionaryToOSD(request));
            }
            catch (Exception)
            {
                return result;
            }

            if (m_AuthenticationService != null)
            {
                //Set password on the incoming region
                if (m_AuthenticationService.CheckExists(aRegion.RegionID))
                {
                    if (m_AuthenticationService.Authenticate(aRegion.RegionID, aRegion.Password.ToString(), 100) == "")
                    {
                        m_log.Warn("[RegionPostHandler]: Authentication failed for region " + aRegion.RegionName);
                        return result;
                    }
                    else
                        m_log.InfoFormat("[RegionPostHandler]: Authentication succeeded for {0}", aRegion.RegionName);
                }
                else
                {
                    m_log.Warn("[RegionPostHandler]: Authentication failed for region " + aRegion.RegionName);
                    return result;
                }
            }

            // Finally!
            List<GridRegion> thisRegion = m_NeighborService.InformNeighborsThatRegionIsDown(aRegion);

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

            if (thisRegion.Count != 0)
            {
                resp["success"] = "true";
                int i = 0;
                foreach (GridRegion r in thisRegion)
                {
                    Dictionary<string, object> region = r.ToKeyValuePairs();
                    resp["region" + i] = region;
                    i++;
                }
            }
            else
                resp["success"] = "false";

            string xmlString = WebUtils.BuildXmlResponse(resp);
            UTF8Encoding encoding = new UTF8Encoding();
            return encoding.GetBytes(xmlString);
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:58,代码来源:NeighbourHandlers.cs

示例5: GetNeighbors

        private byte[] GetNeighbors(Dictionary<string, object> request)
        {
            byte[] result = new byte[0];

            if (!CheckThreatLevel(NeighborThreatLevel.None))
            {
                return result;
            }

            // retrieve the region
            RegionInfo aRegion = new RegionInfo();
            try
            {
                aRegion.UnpackRegionInfoData(Util.DictionaryToOSD(request));
            }
            catch (Exception)
            {
                return result;
            }

            // Finally!
            List<GridRegion> thisRegion = m_NeighborService.GetNeighbors(aRegion);

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

            if (thisRegion.Count != 0)
            {
                resp["success"] = "true";
                int i = 0;
                foreach (GridRegion r in thisRegion)
                {
                    Dictionary<string, object> region = r.ToKeyValuePairs();
                    resp["region" + i] = region;
                    i++;
                }
            }
            else
                resp["success"] = "false";

            string xmlString = WebUtils.BuildXmlResponse(resp);
            UTF8Encoding encoding = new UTF8Encoding();
            return encoding.GetBytes(xmlString);
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:43,代码来源:NeighbourHandlers.cs


注:本文中的OpenSim.Framework.RegionInfo.UnpackRegionInfoData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。