コード例 #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
        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);
        }
コード例 #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.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;
        }
コード例 #7
0
        public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, string sogXml2, bool allowScriptCrossing)
        {
            ulong  regionHandle = GetRegionHandle(region.RegionHandle);
            string uri
                = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort
                  + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/";
            //m_log.Debug("   >>> DoCreateChildAgentCall <<< " + 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(sogXml2);
            args["extra"] = OSD.FromString(sog.ExtraToXmlString());
            if (allowScriptCrossing)
            {
                string state = sog.GetStateSnapshot();
                if (state.Length > 0)
                {
                    args["state"] = OSD.FromString(state);
                }
            }

            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 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
                os.Close();
                m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri);
            }
            //catch (WebException ex)
            catch
            {
                // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message);

                return(false);
            }

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

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

                StreamReader sr = new StreamReader(webResponse.GetResponseStream());
                //reply = sr.ReadToEnd().Trim();
                sr.ReadToEnd().Trim();
                sr.Close();
                //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply);
            }
            catch (WebException ex)
            {
                m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message);
                // ignore, really
            }

            return(true);
        }
コード例 #8
0
ファイル: RegionClient.cs プロジェクト: AlphaStaxLLC/taiga
        public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing)
        {
            ulong regionHandle = GetRegionHandle(region.RegionHandle);
            string uri 
                = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort 
                    + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/";
            //m_log.Debug("   >>> DoCreateChildAgentCall <<< " + 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(sogXml2);
            args["extra"] = OSD.FromString(sog.ExtraToXmlString());
            if (allowScriptCrossing)
            {
                string state = sog.GetStateSnapshot();
                if (state.Length > 0)
                    args["state"] = OSD.FromString(state);
            }

            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("[REST COMMS]: 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("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri);
            }
            //catch (WebException ex)
            catch
            {
                // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", 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 DoCreateChildAgentCall");

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

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

            }
            catch (WebException ex)
            {
                m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message);
                // ignore, really
            }
            finally
            {
                if (sr != null)
                    sr.Close();
            }

            return true;

        }