コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
        {
            // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateObject start");

            string uri = destination.ServerURI + ObjectPath() + sog.UUID + "/";

            try
            {
                OSDMap args = new OSDMap(2);

                args["sog"]      = OSD.FromString(sog.ToXml2());
                args["extra"]    = OSD.FromString(sog.ExtraToXmlString());
                args["modified"] = OSD.FromBoolean(sog.HasGroupChanged);

                string state = sog.GetStateSnapshot();
                if (state.Length > 0)
                {
                    args["state"] = OSD.FromString(state);
                }

                // Add the input general arguments
                args["destination_x"]    = OSD.FromString(destination.RegionLocX.ToString());
                args["destination_y"]    = OSD.FromString(destination.RegionLocY.ToString());
                args["destination_name"] = OSD.FromString(destination.RegionName);
                args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());

                WebUtil.PostToService(uri, args);
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CreateObject failed with exception; {0}", e.ToString());
            }

            return(true);
        }
コード例 #2
0
        public bool CreateObject(GridRegion destination, ISceneObject sog)
        {
            // Try local first
            if (m_localBackend != null && m_localBackend.CreateObject(destination, sog))
            {
                //MainConsole.Instance.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded");
                return(true);
            }

            // else do the remote thing
            bool successful = false;

            if (m_localBackend == null || !m_localBackend.IsLocalRegion(destination.RegionHandle))
            {
                string uri = MakeUri(destination, false) + sog.UUID + "/";
                //MainConsole.Instance.Debug("   >>> DoCreateObjectCall <<< " + uri);

                OSDMap args = new OSDMap(7);
                args["sog"]   = OSD.FromString(sog.ToXml2());
                args["extra"] = OSD.FromString(sog.ExtraToXmlString());
                // Add the input general arguments
                args["destination_x"]    = OSD.FromString(destination.RegionLocX.ToString());
                args["destination_y"]    = OSD.FromString(destination.RegionLocY.ToString());
                args["destination_name"] = OSD.FromString(destination.RegionName);
                args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());

                string result = WebUtils.PostToService(uri, args);
                if (bool.TryParse(result, out successful))
                {
                    return(successful);
                }
            }
            return(successful);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        public bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog, bool isLocalCall)
        {
            // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateObject start");

            string uri = destination.ServerURI + ObjectPath() + sog.UUID + "/";

            try
            {
                OSDMap args = new OSDMap(2);

                args["sog"] = OSD.FromString(sog.ToXml2());
                args["extra"] = OSD.FromString(sog.ExtraToXmlString());
                args["modified"] = OSD.FromBoolean(sog.HasGroupChanged);
                args["new_position"] = newPosition.ToString();

                string state = sog.GetStateSnapshot();
                if (state.Length > 0)
                    args["state"] = OSD.FromString(state);

                // Add the input general arguments
                args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
                args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
                args["destination_name"] = OSD.FromString(destination.RegionName);
                args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());

                WebUtil.PostToService(uri, args, 40000);
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CreateObject failed with exception; {0}",e.ToString());
            }

            return true;
        }
コード例 #4
0
        public bool CreateObject(GridRegion destination, ISceneObject sog)
        {
            // Try local first
            if (m_localBackend != null && m_localBackend.CreateObject(destination, sog))
            {
                //MainConsole.Instance.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded");
                return true;
            }

            // else do the remote thing
            bool successful = false;
            if (m_localBackend == null || !m_localBackend.IsLocalRegion(destination.RegionHandle))
            {
                string uri = MakeUri(destination, false) + sog.UUID + "/";
                //MainConsole.Instance.Debug("   >>> DoCreateObjectCall <<< " + uri);

                OSDMap args = new OSDMap(7);
                args["sog"] = OSD.FromString(sog.ToXml2());
                args["extra"] = OSD.FromString(sog.ExtraToXmlString());
                // Add the input general arguments
                args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
                args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
                args["destination_name"] = OSD.FromString(destination.RegionName);
                args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());

                OSDMap result = WebUtils.PostToService(uri, args, true, false);
                if (bool.TryParse(result["_RawResult"], out successful))
                    return successful;
            }
            return successful;
        }
コード例 #5
0
ファイル: OpenSimComms.cs プロジェクト: diva/Grider
 public static bool CreateObject(RegionInfo region, ISceneObject sog)
 {
     string reason = string.Empty;
     bool success = region_comms.DoCreateObjectCall(region, sog, sog.ToXml2(), true);
     Console.WriteLine("[GridSurfer]: posted object to " + region.ExternalHostName + ":" + region.HttpPort + " -- " + success);
     return success;
 }
コード例 #6
0
        public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
        {
            string uri
                = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + ObjectPath() + sog.UUID + "/";
            //m_log.Debug("   >>> DoCreateObjectCall <<< " + uri);

            WebRequest ObjectCreateRequest = WebRequest.Create(uri);

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

            OSDMap args = new OSDMap(2);

            args["sog"]   = OSD.FromString(sog.ToXml2());
            args["extra"] = OSD.FromString(sog.ExtraToXmlString());
            string state = sog.GetStateSnapshot();

            if (state.Length > 0)
            {
                args["state"] = OSD.FromString(state);
            }
            // Add the input general arguments
            args["destination_x"]    = OSD.FromString(destination.RegionLocX.ToString());
            args["destination_y"]    = OSD.FromString(destination.RegionLocY.ToString());
            args["destination_name"] = OSD.FromString(destination.RegionName);
            args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());

            string strBuffer = "";

            byte[] buffer = new byte[1];
            try
            {
                strBuffer = OSDParser.SerializeJsonString(args);
                Encoding str = Util.UTF8;
                buffer = str.GetBytes(strBuffer);
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of CreateObject: {0}", e.Message);
                // ignore. buffer will be empty, caller should check.
            }

            Stream os = null;

            try
            {                                                      // send the Post
                ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send
                os = ObjectCreateRequest.GetRequestStream();
                os.Write(buffer, 0, strBuffer.Length);             //Send it
                m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateObject request to remote sim {0}", uri);
            }
            catch (WebException ex)
            {
                m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on CreateObject {0}", ex.Message);
                return(false);
            }
            finally
            {
                if (os != null)
                {
                    os.Close();
                }
            }

            // Let's wait for the response
            //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");

            StreamReader sr = null;

            try
            {
                WebResponse webResponse = ObjectCreateRequest.GetResponse();
                if (webResponse == null)
                {
                    m_log.Warn("[REMOTE SIMULATION CONNECTOR]: Null reply on CreateObject post");
                    return(false);
                }

                sr = new StreamReader(webResponse.GetResponseStream());
                //reply = sr.ReadToEnd().Trim();
                sr.ReadToEnd().Trim();
                //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", reply);
            }
            catch (WebException ex)
            {
                m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of CreateObject {0}", ex.Message);
                return(false);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }

            return(true);
        }
コード例 #7
0
        public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
        {
            string uri
                = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + ObjectPath() + sog.UUID + "/";
            //m_log.Debug("   >>> DoCreateObjectCall <<< " + uri);

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

            OSDMap args = new OSDMap(2);
            args["sog"] = OSD.FromString(sog.ToXml2());
            args["extra"] = OSD.FromString(sog.ExtraToXmlString());
            string state = sog.GetStateSnapshot();
            if (state.Length > 0)
                args["state"] = OSD.FromString(state);
            // Add the input general arguments
            args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
            args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
            args["destination_name"] = OSD.FromString(destination.RegionName);
            args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());

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

            }
            catch (Exception e)
            {
                m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of CreateObject: {0}", e.Message);
                // ignore. buffer will be empty, caller should check.
            }

            Stream os = null;
            try
            { // send the Post
                ObjectCreateRequest.ContentLength = buffer.Length;   //Count bytes to send
                os = ObjectCreateRequest.GetRequestStream();
                os.Write(buffer, 0, strBuffer.Length);         //Send it
                m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateObject request to remote sim {0}", uri);
            }
            catch (WebException ex)
            {
                m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on CreateObject {0}", ex.Message);
                return false;
            }
            finally
            {
                if (os != null)
                    os.Close();
            }

            // Let's wait for the response
            //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");

            StreamReader sr = null;
            try
            {
                WebResponse webResponse = ObjectCreateRequest.GetResponse();
                if (webResponse == null)
                {
                    m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on CreateObject post");
                    return false;
                }

                sr = new StreamReader(webResponse.GetResponseStream());
                //reply = sr.ReadToEnd().Trim();
                sr.ReadToEnd().Trim();
                //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", reply);

            }
            catch (WebException ex)
            {
                m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of CreateObject {0}", ex.Message);
                return false;
            }
            finally
            {
                if (sr != null)
                    sr.Close();
            }

            return true;
        }