public bool RetrieveAgent(GridRegion destination, UUID id, bool agentIsLeaving, out AgentData agent, out AgentCircuitData circuitData) { agent = null; // Try local first if (m_localBackend.RetrieveAgent(destination, id, agentIsLeaving, out agent, out circuitData)) { return(true); } // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) { // Eventually, we want to use a caps url instead of the agentID string uri = MakeUri(destination, true) + id + "/" + destination.RegionID.ToString() + "/" + agentIsLeaving.ToString() + "/"; try { string resultStr = WebUtils.GetFromService(uri); if (resultStr != "") { OSDMap result = OSDParser.DeserializeJson(resultStr) as OSDMap; if (result["Result"] == "Not Found") { return(false); } agent = new AgentData(); if (!result.ContainsKey("AgentData")) { return(false); //Disable old simulators } agent.Unpack((OSDMap)result["AgentData"]); circuitData = new AgentCircuitData(); circuitData.UnpackAgentCircuitData((OSDMap)result["CircuitData"]); return(true); } } catch (Exception e) { MainConsole.Instance.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e); } return(false); } return(false); }
private bool UpdateAgent(GridRegion destination, IAgentData cAgentData) { // Try local first if (cAgentData is AgentData) { if (m_localBackend.UpdateAgent(destination, (AgentData)cAgentData)) { return(true); } } else if (cAgentData is AgentPosition) { if (m_localBackend.UpdateAgent(destination, (AgentPosition)cAgentData)) { return(true); } } // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) { // Eventually, we want to use a caps url instead of the agentID string uri = MakeUri(destination, true) + cAgentData.AgentID + "/"; if (m_blackListedRegions.ContainsKey(uri)) { //Check against time if (Util.EnvironmentTickCountSubtract(m_blackListedRegions[uri]) > 0) { //Still blacklisted return(false); } } try { OSDMap args = cAgentData.Pack(); 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.PutToService(uri, args); if (!result["Success"].AsBoolean()) { //add it to the blacklist m_blackListedRegions[uri] = Util.EnvironmentTickCount() + 60 * 1000; //60 seconds return(result["Success"].AsBoolean()); } //Clear out the blacklist if it went through m_blackListedRegions.Remove(uri); OSDMap innerResult = (OSDMap)result["_Result"]; return(innerResult["Updated"].AsBoolean()); } catch (Exception e) { m_log.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e.ToString()); } return(false); } return(false); }