Ejemplo n.º 1
0
 public static void ActionFailed(CpAction action, object clientState, string errorDescription)
 {
   action.ActionErrorResultPresent(new UPnPError(501, errorDescription), clientState);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Takes the XML document provided by the given <paramref name="body"/> stream, parses it in the given
 /// <paramref name="contentEncoding"/> and provides the action result to the appropriate receiver.
 /// </summary>
 /// <param name="body">Body stream of the SOAP XML action result message.</param>
 /// <param name="contentEncoding">Encoding of the body stream.</param>
 /// <param name="action">Action which was called before.</param>
 /// <param name="clientState">State object which was given in the action call and which will be returned to the client.</param>
 /// <param name="upnpVersion">UPnP version of the UPnP server.</param>
 public static void HandleResult(Stream body, Encoding contentEncoding, CpAction action, object clientState, UPnPVersion upnpVersion)
 {
   bool sourceSupportsUPnP11 = upnpVersion.VerMin >= 1;
   IList<object> outParameterValues;
   try
   {
     if (!body.CanRead)
     {
       UPnPConfiguration.LOGGER.Error("SOAPHandler: Empty action result document");
       action.ActionErrorResultPresent(new UPnPError(501, "Invalid server result"), clientState);
       return;
     }
     using (TextReader textReader = new StreamReader(body, contentEncoding))
       outParameterValues = ParseResult(textReader, action, sourceSupportsUPnP11);
   }
   catch (Exception e)
   {
     UPnPConfiguration.LOGGER.Error("SOAPHandler: Error parsing action result document", e);
     action.ActionErrorResultPresent(new UPnPError(501, "Invalid server result"), clientState);
     return;
   }
   try
   {
     // Invoke action result
     action.ActionResultPresent(outParameterValues, clientState);
   }
   catch (Exception e)
   {
     UPnPConfiguration.LOGGER.Error("UPnP subsystem: Error invoking action '{0}'", e, action.FullQualifiedName);
   }
 }
Ejemplo n.º 3
0
 public static void HandleErrorResult(TextReader textReader, CpAction action, object clientState)
 {
   try
   {
     uint errorCode;
     string errorDescription;
     ParseFaultDocument(textReader, out errorCode, out errorDescription);
     action.ActionErrorResultPresent(new UPnPError(errorCode, errorDescription), clientState);
   }
   catch (Exception e)
   {
     UPnPConfiguration.LOGGER.Error("SOAPHandler: Error parsing action error result document", e);
     ActionFailed(action, clientState, "Invalid server result");
   }
 }