/** * Object-related communications */ public bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog, bool isLocalCall) { if (destination == null) { return(false); } if (m_scenes.ContainsKey(destination.RegionID)) { // m_log.DebugFormat( // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", // s.RegionInfo.RegionName, destination.RegionHandle); Scene s = m_scenes[destination.RegionID]; if (isLocalCall) { // We need to make a local copy of the object ISceneObject sogClone = sog.CloneForNewScene(); sogClone.SetState(sog.GetStateSnapshot(), s); return(s.IncomingCreateObject(newPosition, sogClone)); } else { // Use the object as it came through the wire return(s.IncomingCreateObject(newPosition, sog)); } } return(false); }
/// <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); }
/** * Object-related communications */ public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) { if (destination == null) { return(false); } foreach (Scene s in m_sceneList) { if (s.RegionInfo.RegionHandle == destination.RegionHandle) { //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); if (isLocalCall) { // We need to make a local copy of the object ISceneObject sogClone = sog.CloneForNewScene(); sogClone.SetState(sog.GetStateSnapshot(), s); return(s.IncomingCreateObject(sogClone)); } else { // Use the object as it came through the wire return(s.IncomingCreateObject(sog)); } } } return(false); }
/// <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; }
/** * Object-related communications */ public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) { if (destination == null) return false; foreach (Scene s in m_sceneList) { if (s.RegionInfo.RegionHandle == destination.RegionHandle) { //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); if (isLocalCall) { // We need to make a local copy of the object ISceneObject sogClone = sog.CloneForNewScene(s); sogClone.SetState(sog.GetStateSnapshot(), s); return s.IncomingCreateObject(sogClone); } else { // Use the object as it came through the wire return s.IncomingCreateObject(sog); } } } return false; }
/** * Object-related communications */ public bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog, bool isLocalCall) { if (destination == null) return false; if (m_scenes.ContainsKey(destination.RegionID)) { // m_log.DebugFormat( // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", // s.RegionInfo.RegionName, destination.RegionHandle); Scene s = m_scenes[destination.RegionID]; if (isLocalCall) { // We need to make a local copy of the object ISceneObject sogClone = sog.CloneForNewScene(); sogClone.SetState(sog.GetStateSnapshot(), s); return s.IncomingCreateObject(newPosition, sogClone); } else { // Use the object as it came through the wire return s.IncomingCreateObject(newPosition, sog); } } return false; }
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); }
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; }
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); }
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; }
public bool CreateObject(GridRegion destination, ISceneObject sog) { // Try local first if (m_localBackend.CreateObject(destination, sog)) { //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); return true; } // else do the remote thing bool successful = false; if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) { string uri = MakeUri(destination, ObjectPath()) + sog.UUID + "/"; //m_log.Debug(" >>> DoCreateObjectCall <<< " + uri); OSDMap args = new OSDMap(7); 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()); OSDMap result = WebUtils.PostToService(uri, args); if (bool.TryParse(result["_RawResult"], out successful)) return successful; } return successful; }