Beispiel #1
0
        public XmlRpcResponse XmlRpcCommand(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            XmlRpcResponse response     = new XmlRpcResponse();
            Hashtable      responseData = new Hashtable();

            try
            {
                responseData["Status"] = "Success";
                responseData["Value"]  = "";

                XmlMethodHandler handler = LookupCommand(request.MethodNameObject, request.MethodNameMethod);

                if (handler != null)
                {
                    responseData["Value"] = handler(request.Params, remoteClient);
                    response.Value        = responseData;
                }
                else
                {
                    // Code set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
                    response.SetFault(
                        XmlRpcErrorCodes.SERVER_ERROR_METHOD,
                        String.Format("Requested method [{0}] not found", request.MethodNameObject + "." + request.MethodNameMethod));
                }
            }
            catch (Exception e)
            {
                responseData["Status"]           = "Failure";
                responseData["ErrorDescription"] = e.Message;
                response.Value = responseData;
            }

            return(response);
        }
Beispiel #2
0
 public void AddCommand(string classname, string command, XmlMethodHandler method)
 {
     lock (m_commands)
     {
         if (!m_commands.ContainsKey(classname))
         {
             m_commands.Add(classname, new Dictionary <string, XmlMethodHandler>());
         }
         m_commands[classname].Add(command, method);
     }
 }
Beispiel #3
0
 public void RemoveCommand(string classname, string command, XmlMethodHandler method)
 {
     lock (m_commands)
     {
         if (!m_commands.ContainsKey(classname))
         {
             return;
         }
         m_commands[classname].Remove(command);
     }
 }
Beispiel #4
0
 public void AddCommand(string classname, string command, XmlMethodHandler method)
 {
     lock (m_commands)
     {
         if (!m_commands.ContainsKey(classname))
             m_commands.Add(classname, new Dictionary<string, XmlMethodHandler>());
         m_commands[classname].Add(command, method);
     }
 }
Beispiel #5
0
 public void RemoveCommand(string classname, string command, XmlMethodHandler method)
 {
     lock (m_commands)
     {
         if (!m_commands.ContainsKey(classname))
             return;
         m_commands[classname].Remove(command);
     }
 }