/// <summary> /// This is the worker function to send AgentData to a neighbor region /// </summary> private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, EntityTransferContext ctx, int timeout) { // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI); // Eventually, we want to use a caps url instead of the agentID string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/"; try { OSDMap args = cAgentData.Pack(ctx); 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()); args["context"] = ctx.Pack(); OSDMap result = WebUtil.PutToServiceCompressed(uri, args, timeout); if (result["Success"].AsBoolean()) { return(true); } result = WebUtil.PutToService(uri, args, timeout); return(result["Success"].AsBoolean()); } catch (Exception e) { m_log.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e.ToString()); } return(false); }
public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List <UUID> featuresAvailable, EntityTransferContext ctx, out string reason) { Culture.SetCurrentCulture(); reason = "Failed to contact destination"; // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position); // Eventually, we want to use a caps url instead of the agentID string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/"; OSDMap request = new OSDMap(); request.Add("viaTeleport", OSD.FromBoolean(viaTeleport)); request.Add("position", OSD.FromString(position.ToString())); // To those who still understad this field, we're telling them // the lowest version just to be safe request.Add("my_version", OSD.FromString(String.Format("SIMULATION/{0}", VersionInfo.SimulationServiceVersionSupportedMin))); // New simulation service negotiation request.Add("simulation_service_supported_min", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMin)); request.Add("simulation_service_supported_max", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMax)); request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin)); request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax)); request.Add("context", ctx.Pack()); OSDArray features = new OSDArray(); foreach (UUID feature in featuresAvailable) { features.Add(OSD.FromString(feature.ToString())); } request.Add("features", features); if (agentHomeURI != null) { request.Add("agent_home_uri", OSD.FromString(agentHomeURI)); } OSD tmpOSD; try { OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false, true); bool success = result["success"].AsBoolean(); bool has_Result = false; if (result.TryGetValue("_Result", out tmpOSD)) { has_Result = true; OSDMap data = (OSDMap)tmpOSD; // FIXME: If there is a _Result map then it's the success key here that indicates the true success // or failure, not the sibling result node. //nte4.8 crap success = data["success"].AsBoolean(); reason = data["reason"].AsString(); // We will need to plumb this and start sing the outbound version as well // TODO: lay the pipe for version plumbing if (data.TryGetValue("negotiated_inbound_version", out tmpOSD) && tmpOSD != null) { ctx.InboundVersion = (float)tmpOSD.AsReal(); ctx.OutboundVersion = (float)data["negotiated_outbound_version"].AsReal(); } else if (data.TryGetValue("version", out tmpOSD) && tmpOSD != null) { string versionString = tmpOSD.AsString(); if (versionString != string.Empty) { String[] parts = versionString.Split(new char[] { '/' }); if (parts.Length > 1) { ctx.InboundVersion = float.Parse(parts[1], Culture.FormatProvider); ctx.OutboundVersion = float.Parse(parts[1], Culture.FormatProvider); } } } m_log.DebugFormat( "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}", uri, success, reason, ctx.InboundVersion, ctx.OutboundVersion); } if (!success || ctx.InboundVersion == 0f || ctx.OutboundVersion == 0f) { // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the // actual failure message if (!has_Result) { if (result.TryGetValue("Message", out tmpOSD)) { string message = tmpOSD.AsString(); if (message == "Service request failed: [MethodNotAllowed] MethodNotAllowed") // Old style region { m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored"); return(true); } reason = result["Message"]; } else { reason = "Communications failure"; } } return(false); } featuresAvailable.Clear(); if (result.TryGetValue("features", out tmpOSD) && tmpOSD is OSDArray) { OSDArray array = (OSDArray)tmpOSD; foreach (OSD o in array) { featuresAvailable.Add(new UUID(o.AsString())); } } // Version stuff if (ctx.OutboundVersion < 0.5) { ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES; } else if (ctx.OutboundVersion < 0.6) { ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES + 1; } else { ctx.WearablesCount = -1; // send all (just in case..) } return(success); } catch (Exception e) { m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] QueryAcesss failed with exception; {0}", e.ToString()); } return(false); }
public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string myipaddress, out string reason) { m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI); reason = String.Empty; myipaddress = String.Empty; if (destination == null) { reason = "Destination not found"; m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null"); return(false); } string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/"; try { OSDMap args = aCircuit.PackAgentCircuitData(ctx); args["context"] = ctx.Pack(); PackData(args, source, aCircuit, destination, flags); OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); bool success = result["success"].AsBoolean(); if (success && result.ContainsKey("_Result")) { OSDMap data = (OSDMap)result["_Result"]; reason = data["reason"].AsString(); success = data["success"].AsBoolean(); myipaddress = data["your_ip"].AsString(); return(success); } // Try the old version, uncompressed result = WebUtil.PostToService(uri, args, 30000, false); if (result["Success"].AsBoolean()) { if (result.ContainsKey("_Result")) { OSDMap data = (OSDMap)result["_Result"]; reason = data["reason"].AsString(); success = data["success"].AsBoolean(); myipaddress = data["your_ip"].AsString(); m_log.WarnFormat( "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); return(success); } } m_log.WarnFormat( "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {2}", aCircuit.firstname, aCircuit.lastname, destination.RegionName); reason = result["Message"] != null ? result["Message"].AsString() : "error"; return(false); } catch (Exception e) { m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString()); reason = e.Message; } return(false); }