public override void ProcessRequest(string request, ref Socket socket, bool authenticated, string body) { QueryString query = new QueryString(request); String sMimeType = "_Text/xml"; String data = XmlRpcMethod.DispatchRpcCall(body); SendHeaderAndData(data, ref socket, sMimeType); }
public static string DispatchRpcCall(string data) { XmlDocument doc = new XmlDocument(); doc.LoadXml(data); XmlNode nodeMethod = doc["methodCall"]; string methodName = nodeMethod["methodName"].InnerText; if (RpcDispatchMap.ContainsKey(methodName)) { XmlRpcMethod method = RpcDispatchMap[methodName]; return(method.Dispatch(nodeMethod)); } return("<?xml version='1.0' encoding='UTF-8'?>\r\n<methodResponse>\r\n<params>\r\n<param>\r\n<value></value>\r\n</param>\r\n</params>\n</methodResponse>\r\n"); }
public static void RegisterDispatchMap(XmlRpcMethod method) { RpcDispatchMap.Add(method.Name, method); }
public bool Startup() { if (Earth3d.Logging) { Earth3d.WriteLogMessage("Starting Web Server"); } SetAccessLists(); if (!initializedOnce) { RequestHandler.RegisterHandler(new HTTPImagesetWtml()); RequestHandler.RegisterHandler(new HTTPLayerApi()); RequestHandler.RegisterHandler(new HttpXmlRpc()); RequestHandler.RegisterHandler(new HttpImageFiles()); RequestHandler.RegisterHandler(new HttpCrossDomain()); RequestHandler.RegisterHandler(new HttpClientStatus()); XmlRpcMethod.RegisterDispatchMap(new SampClientReceiveNotification()); initializedOnce = true; } try { // Find IPV4 Address _bQuit = false; IpAddress = ""; listeners.Clear(); WebListener listener = null; foreach (IPAddress ipAdd in Dns.GetHostEntry(Dns.GetHostName()).AddressList) { if (ipAdd.AddressFamily == AddressFamily.InterNetwork) { if (string.IsNullOrEmpty(IpAddress)) { IpAddress = ipAdd.ToString(); } if (ipAdd.ToString() != "127.0.0.1") { if (Earth3d.Logging) { Earth3d.WriteLogMessage(" Web Server - Adding:" + ipAdd.ToString()); } listener = new WebListener(new ParameterizedThreadStart(ListenerThreadFunc), ipAdd); listeners.Add(listener); listener.Start(); } } } if (Earth3d.Logging) { Earth3d.WriteLogMessage(" Web Server - Adding Loopback"); } // Add Loopback localhost listener = new WebListener(new ParameterizedThreadStart(ListenerThreadFunc), IPAddress.Loopback); listeners.Add(listener); listener.Start(); } catch (Exception e) { if (Earth3d.Logging) { Earth3d.WriteLogMessage("Failed Starting Web Server"); Earth3d.WriteLogMessage(e.Message); Earth3d.WriteLogMessage(e.Source); Earth3d.WriteLogMessage(e.StackTrace); } _bQuit = true; return(false); } return(true); }