public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) { XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); m_log.Info("[RADMIN]: Load height maps request started"); try { Hashtable requestData = (Hashtable) request.Params[0]; m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request.ToString()); // foreach (string k in requestData.Keys) // { // m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}: >{1}< {2}", // k, (string)requestData[k], ((string)requestData[k]).Length); // } CheckStringParameters(request, new string[] {"password", "filename", "regionid"}); if (m_requiredPassword != String.Empty && (!requestData.Contains("password") || (string) requestData["password"] != m_requiredPassword)) throw new Exception("wrong password"); string file = (string) requestData["filename"]; UUID regionID = (UUID) (string) requestData["regionid"]; m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); responseData["accepted"] = true; IScene region = null; if (!manager.TryGetScene(regionID, out region)) throw new Exception("1: unable to get a scene with that name"); ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); if (null == terrainModule) throw new Exception("terrain module not available"); if (Uri.IsWellFormedUriString(file, UriKind.Absolute)) { m_log.Info("[RADMIN]: Terrain path is URL"); Uri result; if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result)) { // the url is valid string fileType = file.Substring(file.LastIndexOf('/') + 1); terrainModule.LoadFromStream(fileType, result); } } else { terrainModule.LoadFromFile(file, 0, 0); } responseData["success"] = false; response.Value = responseData; } catch (Exception e) { m_log.ErrorFormat("[RADMIN]: Terrain Loading: failed: {0}", e.Message); m_log.DebugFormat("[RADMIN]: Terrain Loading: failed: {0}", e.ToString()); responseData["success"] = false; responseData["error"] = e.Message; } m_log.Info("[RADMIN]: Load height maps request complete"); return response; }
public XmlRpcResponse XmlRpcSaveHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) { XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); m_log.Info("[RADMIN]: Save height maps request started"); try { Hashtable requestData = (Hashtable)request.Params[0]; m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString()); CheckStringParameters(request, new string[] { "password", "filename", "regionid" }); if (m_requiredPassword != String.Empty && (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword)) throw new Exception("wrong password"); string file = (string)requestData["filename"]; UUID regionID = (UUID)(string)requestData["regionid"]; m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file); responseData["accepted"] = true; Scene region = null; if (!m_application.SceneManager.TryGetScene(regionID, out region)) throw new Exception("1: unable to get a scene with that name"); ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); if (null == terrainModule) throw new Exception("terrain module not available"); terrainModule.SaveToFile(file); responseData["success"] = false; response.Value = responseData; } catch (Exception e) { m_log.ErrorFormat("[RADMIN]: Terrain Saving: failed: {0}", e.Message); m_log.DebugFormat("[RADMIN]: Terrain Saving: failed: {0}", e.ToString()); responseData["success"] = false; responseData["error"] = e.Message; } m_log.Info("[RADMIN]: Save height maps request complete"); return response; }
public override object Execute(out Hashtable outputParams) { // assign output params outputParams = null; Hashtable outputPlaceholder = null; // create new XmlRpcRequest object XmlRpcRequest client = new XmlRpcRequest(); // fill in the concrete method name client.MethodName = Call.Renderer.Voc.GetMethodCmp(Call.MethodName, Call.ObjectName); // provide the input parameters Uiml.Param[] parameters = Call.Renderer.Voc.GetMethodParams(Call.ObjectName, Call.MethodName); Type[] tparamTypes = null; try { tparamTypes = CreateInOutParamTypes(parameters, out outputPlaceholder); } catch(ArgumentOutOfRangeException) { return null; } for (int k = 0; k < parameters.Length; k++) { string propValue = (string) ((Uiml.Executing.Param) Call.Params[k]).Value(Call.Renderer); client.Params.Add(Call.Renderer.Decoder.GetArg(propValue, tparamTypes[k])); } if (m_request == null || !client.ToString().Equals(m_request.ToString())) { XmlRpcResponse response = client.Send(m_url); // cache response and request m_request = client; m_response = response; } if (m_response.IsFault) { Console.WriteLine("Fault {0}: {1}", m_response.FaultCode, m_response.FaultString); return null; } else { return m_response.Value; } }