/// <summary> /// Get GridInfo in json format: Used by the OSSL osGetGrid* /// Adding the SRV_HomeIRI to the kvp returned for use in scripts /// </summary> /// <returns> /// json string /// </returns> /// </param> /// <param name='httpRequest'> /// Http request. /// </param> /// <param name='httpResponse'> /// Http response. /// </param> public void JsonGetGridInfoMethod(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { httpResponse.KeepAlive = false; if (httpRequest.HttpMethod != "GET") { httpResponse.StatusCode = (int)HttpStatusCode.MethodNotAllowed; return; } OSDMap map = new OSDMap(); foreach (string k in _info.Keys) { map[k] = OSD.FromString(_info[k].ToString()); } string HomeURI = Util.GetConfigVarFromSections <string>(m_Config, "HomeURI", new string[] { "Startup", "Hypergrid" }, String.Empty); if (!string.IsNullOrEmpty(HomeURI)) { map["home"] = OSD.FromString(HomeURI); } else // Legacy. Remove soon! { IConfig cfg = m_Config.Configs["LoginService"]; if (null != cfg) { HomeURI = cfg.GetString("SRV_HomeURI", HomeURI); } if (!string.IsNullOrEmpty(HomeURI)) { map["home"] = OSD.FromString(HomeURI); } } httpResponse.RawBuffer = OSDParser.SerializeJsonToBytes(map); }
protected void DoAgentPost(OSDMap args, string remoteAddress, IOSHttpResponse response, UUID id) { OSD tmpOSD; EntityTransferContext ctx = new EntityTransferContext(); if (args.TryGetValue("context", out tmpOSD) && tmpOSD is OSDMap) { ctx.Unpack((OSDMap)tmpOSD); } AgentDestinationData data = CreateAgentDestinationData(); UnpackData(args, data, remoteAddress); GridRegion destination = new GridRegion(); destination.RegionID = data.uuid; destination.RegionLocX = data.x; destination.RegionLocY = data.y; destination.RegionName = data.name; GridRegion gatekeeper = ExtractGatekeeper(data); AgentCircuitData aCircuit = new AgentCircuitData(); try { aCircuit.UnpackAgentCircuitData(args); } catch (Exception ex) { m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); response.StatusCode = (int)HttpStatusCode.BadRequest; return; } GridRegion source = null; if (args.TryGetValue("source_uuid", out tmpOSD)) { source = new GridRegion(); source.RegionID = UUID.Parse(tmpOSD.AsString()); source.RegionLocX = Int32.Parse(args["source_x"].AsString()); source.RegionLocY = Int32.Parse(args["source_y"].AsString()); source.RegionName = args["source_name"].AsString(); if (args.TryGetValue("source_server_uri", out tmpOSD)) { source.RawServerURI = tmpOSD.AsString(); } else { source.RawServerURI = null; } } OSDMap resp = new OSDMap(2); string reason = string.Empty; bool result = CreateAgent(source, gatekeeper, destination, aCircuit, data.flags, data.fromLogin, ctx, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); // Let's also send out the IP address of the caller back to the caller (HG 1.5) resp["your_ip"] = remoteAddress; response.StatusCode = (int)HttpStatusCode.OK; response.RawBuffer = OSDParser.SerializeJsonToBytes(resp); }