/// <summary> /// Not sure what sequence causes this function to be invoked. The only calling /// path is through the GET method /// </summary> public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) { // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: RetrieveAgent start"); agent = null; // Eventually, we want to use a caps url instead of the agentID string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; try { OSDMap result = WebUtil.GetFromService(uri); if (result["Success"].AsBoolean()) { // OSDMap args = Util.GetOSDMap(result["_RawResult"].AsString()); OSDMap args = (OSDMap)result["_Result"]; if (args != null) { agent = new CompleteAgentData(); agent.Unpack(args, null); return(true); } } } catch (Exception e) { m_log.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e.ToString()); } return(false); }
public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) { agent = null; // Eventually, we want to use a caps url instead of the agentID string uri = "http://" + region.ExternalHostName + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "GET"; request.Timeout = 10000; //request.Headers.Add("authorization", String.Empty); // coming soon request.Headers["authorization"] = GenerateAuthorization(); HttpWebResponse webResponse = null; string reply = String.Empty; try { webResponse = (HttpWebResponse)request.GetResponse(); if (webResponse == null) { m_log.Info("[REST COMMS]: Null reply on agent get "); return(false); } StreamReader sr = new StreamReader(webResponse.GetResponseStream()); reply = sr.ReadToEnd().Trim(); sr.Close(); //Console.WriteLine("[REST COMMS]: ChildAgentUpdate reply was " + reply); } catch (WebException ex) { m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); // ignore, really return(false); } if (webResponse.StatusCode == HttpStatusCode.OK) { // we know it's jason OSDMap args = GetOSDMap(reply); if (args == null) { //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); return(false); } agent = new CompleteAgentData(); agent.Unpack(args); return(true); } //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); return(false); }
public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) { agent = null; // Eventually, we want to use a caps url instead of the agentID string uri = "http://" + region.ExternalHostName + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "GET"; request.Timeout = 10000; //request.Headers.Add("authorization", ""); // coming soon request.Headers["authorization"] = GenerateAuthorization(); HttpWebResponse webResponse = null; string reply = string.Empty; try { webResponse = (HttpWebResponse)request.GetResponse(); if (webResponse == null) { m_log.Info("[REST COMMS]: Null reply on agent get "); return false; } StreamReader sr = new StreamReader(webResponse.GetResponseStream()); reply = sr.ReadToEnd().Trim(); sr.Close(); //Console.WriteLine("[REST COMMS]: ChildAgentUpdate reply was " + reply); } catch (WebException ex) { m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); // ignore, really return false; } if (webResponse.StatusCode == HttpStatusCode.OK) { // we know it's jason OSDMap args = GetOSDMap(reply); if (args == null) { //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); return false; } agent = new CompleteAgentData(); agent.Unpack(args); return true; } //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); return false; }
public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) { agent = null; // Eventually, we want to use a caps url instead of the agentID string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "GET"; request.Timeout = 10000; //request.Headers.Add("authorization", ""); // coming soon HttpWebResponse webResponse = null; string reply = string.Empty; StreamReader sr = null; try { webResponse = (HttpWebResponse)request.GetResponse(); if (webResponse == null) { m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Null reply on agent get "); } sr = new StreamReader(webResponse.GetResponseStream()); reply = sr.ReadToEnd().Trim(); //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was " + reply); } catch (WebException ex) { m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent get {0}", ex.Message); // ignore, really return(false); } finally { if (sr != null) { sr.Close(); } } if (webResponse.StatusCode == HttpStatusCode.OK) { // we know it's jason OSDMap args = Util.GetOSDMap(reply); if (args == null) { //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: Error getting OSDMap from reply"); return(false); } agent = new CompleteAgentData(); agent.Unpack(args); return(true); } //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); return(false); }