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


C# RegionInfo.PackRegionInfoData方法代码示例

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


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

示例1: DoHelloNeighbourCall

        public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion)
        {
            string uri = region.ServerURI + "region/" + thisRegion.RegionID + "/";
//            m_log.Debug("   >>> DoHelloNeighbourCall <<< " + uri);

            WebRequest helloNeighbourRequest;

            try
            {
                helloNeighbourRequest = WebRequest.Create(uri);
            }
            catch (Exception e)
            {
                m_log.Warn(string.Format(
                    "[NEIGHBOUR SERVICES CONNECTOR]: Unable to parse uri {0} to send HelloNeighbour from {1} to {2}.  Exception {3} ",
                    uri, thisRegion.RegionName, region.RegionName, e.Message), e);

                return false;
            }

            helloNeighbourRequest.Method = "POST";
            helloNeighbourRequest.ContentType = "application/json";
            helloNeighbourRequest.Timeout = 10000;

            // Fill it in
            OSDMap args = null;
            try
            {
                args = thisRegion.PackRegionInfoData();
            }
            catch (Exception e)
            {
                m_log.Warn(string.Format(
                    "[NEIGHBOUR SERVICES CONNECTOR]: PackRegionInfoData failed for HelloNeighbour from {0} to {1}.  Exception {2} ",
                    thisRegion.RegionName, region.RegionName, e.Message), e);

                return false;
            }

            // Add the regionhandle of the destination region
            args["destination_handle"] = OSD.FromString(region.RegionHandle.ToString());

            string strBuffer = "";
            byte[] buffer = new byte[1];

            try
            {
                strBuffer = OSDParser.SerializeJsonString(args);
                buffer = Util.UTF8NoBomEncoding.GetBytes(strBuffer);
            }
            catch (Exception e)
            {
                m_log.Warn(string.Format(
                    "[NEIGHBOUR SERVICES CONNECTOR]: Exception thrown on serialization of HelloNeighbour from {0} to {1}.  Exception {2} ",
                    thisRegion.RegionName, region.RegionName, e.Message), e);

                return false;
            }

            Stream os = null;
            try
            { // send the Post
                helloNeighbourRequest.ContentLength = buffer.Length;   //Count bytes to send
                os = helloNeighbourRequest.GetRequestStream();
                os.Write(buffer, 0, strBuffer.Length);         //Send it
                //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri);
            }
            catch (Exception e)
            {
//                m_log.WarnFormat(
//                    "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}.  Exception {2}{3}",
//                    thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);

                return false;
            }
            finally
            {
                if (os != null)
                    os.Dispose();
            }

            // Let's wait for the response
            //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall");

            try
            {
                using (WebResponse webResponse = helloNeighbourRequest.GetResponse())
                {
                    if (webResponse == null)
                    {
                        m_log.DebugFormat(
                            "[NEIGHBOUR SERVICES CONNECTOR]: Null reply on DoHelloNeighbourCall post from {0} to {1}",
                            thisRegion.RegionName, region.RegionName);
                    }

                    using (Stream s = webResponse.GetResponseStream())
                    {
                        using (StreamReader sr = new StreamReader(s))
                        {
                            //reply = sr.ReadToEnd().Trim();
//.........这里部分代码省略.........
开发者ID:CassieEllen,项目名称:opensim,代码行数:101,代码来源:NeighbourServicesConnector.cs

示例2: InformNeighborOfChatMessage

        protected void InformNeighborOfChatMessage(OSChatMessage message, ChatSourceType type, GridRegion region, RegionInfo thisRegion)
        {
            string uri = MakeUri(region, "/region/" + thisRegion.RegionID + "/");
            //m_log.Debug("   >>> DoHelloNeighbourCall <<< " + uri);

            // Fill it in
            Dictionary<string, object> args = new Dictionary<string, object>();

            try
            {
                args = Util.OSDToDictionary(thisRegion.PackRegionInfoData());
            }
            catch (Exception e)
            {
                m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message);
                return;
            }
            args["MESSAGE"] = WebUtils.BuildQueryString(message.ToKVP());
            args["TYPE"] = (int)type;
            args["METHOD"] = "inform_neighbors_of_chat_message";

            string queryString = WebUtils.BuildQueryString(args);
            SynchronousRestFormsRequester.MakeRequest("POST", uri, queryString);
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:24,代码来源:NeighbourServiceConnector.cs

示例3: PackRegionInfo

 private Dictionary<string, object> PackRegionInfo(RegionInfo thisRegion, UUID uUID)
 {
     if (m_KnownNeighborsPass.ContainsKey(uUID))
     {
         List<NeighborPassword> passes = m_KnownNeighborsPass[uUID];
         lock (passes)
         {
             foreach (NeighborPassword p in passes)
             {
                 if (thisRegion.RegionID == p.RegionID)
                 {
                     thisRegion.Password = p.Password;
                     break;
                 }
             }
         }
     }
     return Util.OSDToDictionary(thisRegion.PackRegionInfoData());
 }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:19,代码来源:NeighbourServiceConnector.cs

示例4: DoHelloNeighbourCall

        public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion)
        {
            string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/";
            //m_log.Debug("   >>> DoHelloNeighbourCall <<< " + uri);

            WebRequest HelloNeighbourRequest = WebRequest.Create(uri);
            HelloNeighbourRequest.Method = "POST";
            HelloNeighbourRequest.ContentType = "application/json";
            HelloNeighbourRequest.Timeout = 10000;

            // Fill it in
            OSDMap args = null;
            try
            {
                args = thisRegion.PackRegionInfoData();
            }
            catch (Exception e)
            {
                m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message);
                return false;
            }
            // Add the regionhandle of the destination region
            args["destination_handle"] = OSD.FromString(region.RegionHandle.ToString());

            string strBuffer = "";
            byte[] buffer = new byte[1];
            try
            {
                strBuffer = OSDParser.SerializeJsonString(args);
                UTF8Encoding str = new UTF8Encoding();
                buffer = str.GetBytes(strBuffer);

            }
            catch (Exception e)
            {
                m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message);
                return false;
            }

            Stream os = null;
            try
            { // send the Post
                HelloNeighbourRequest.ContentLength = buffer.Length;   //Count bytes to send
                os = HelloNeighbourRequest.GetRequestStream();
                os.Write(buffer, 0, strBuffer.Length);         //Send it
                //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[REST COMMS]: Unable to send HelloNeighbour to {0}: {1}", region.RegionName, ex.Message);
                return false;
            }
            finally
            {
                if (os != null)
                    os.Close();
            }

            // Let's wait for the response
            //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall");

            StreamReader sr = null;
            try
            {
                WebResponse webResponse = HelloNeighbourRequest.GetResponse();
                if (webResponse == null)
                {
                    m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post");
                }

                sr = new StreamReader(webResponse.GetResponseStream());
                //reply = sr.ReadToEnd().Trim();
                sr.ReadToEnd().Trim();
                //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);

            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message);
                return false;
            }
            finally
            {
                if (sr != null)
                    sr.Close();
            }

            return true;

        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:90,代码来源:NeighbourServiceConnector.cs


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