Esempio n. 1
0
        /// <summary>
        /// Gets the output parameters of an formerly invoked action call.
        /// </summary>
        /// <remarks>
        /// If the action invocation isn't completed yet, this method blocks the calling thread until the action invocation
        /// either completes successfully or with an error.
        /// </remarks>
        /// <param name="result">Return value from the former <see cref="BeginInvokeAction"/> call.</param>
        /// <returns>List of output arguments of the called action.</returns>
        /// <exception cref="UPnPException">If an error occured during the action call.</exception>
        public IList <object> EndInvokeAction(IAsyncResult result)
        {
            AsyncActionCallResult ar = result as AsyncActionCallResult;

            if (ar == null)
            {
                throw new IllegalCallException("Provided 'result' parameter doesn't belong to a 'BeginInvokeAction' call (action '{0}')");
            }
            try
            {
                return(ar.GetOutParams());
            }
            catch (Exception e)
            {
                throw new UPnPException("Error invoking action '{0}'", e, _name);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Invokes this action with the given <paramref name="inParameters"/> asynchronously.
        /// </summary>
        /// <remarks>
        /// This method will start the action call request asynchronously and will return immediately.
        /// The UPnP system invokes the provided <paramref name="callback"/> when the action result (or error message)
        /// returns. The call structure corresponds to the asynchronous call pattern used in the .net library.
        /// </remarks>
        /// <param name="inParameters">Input parameters for the action invocation. Must match the formal input arguments.
        /// Can be <c>null</c> if the parameter list is empty.</param>
        /// <param name="callback">Callback delegate to be invoked when the action result is present.</param>
        /// <param name="state">This object can be used to pass state information for the asynchronous operation.</param>
        /// <returns>Async result object which should be used as parameter for the <see cref="EndInvokeAction"/> method.</returns>
        public IAsyncResult BeginInvokeAction(IList <object> inParameters, AsyncCallback callback, object state)
        {
            if (_parentService == null)
            {
                throw new IllegalCallException("Action '{0}' isn't assigned to a service", _name);
            }
            if (!MatchesSignature(inParameters))
            {
                throw new IllegalCallException("The given parameters don't match the formal input arguments of action '{0}'", _name);
            }
            if (!IsConnected)
            {
                throw new UPnPDisconnectedException("Action '{0}' isn't connected to a UPnP network action", _name);
            }
            AsyncActionCallResult ar = new AsyncActionCallResult(callback, state);

            _connection.OnActionCalled(this, inParameters, ar);
            return(ar);
        }
Esempio n. 3
0
        internal void ActionErrorResultPresent(UPnPError error, object handle)
        {
            AsyncActionCallResult asyncResult = (AsyncActionCallResult)handle;

            asyncResult.ActionErrorResultPresent(error);
        }
Esempio n. 4
0
        internal void ActionResultPresent(IList <object> outParams, object handle)
        {
            AsyncActionCallResult asyncResult = (AsyncActionCallResult)handle;

            asyncResult.ActionResultPresent(outParams);
        }
Esempio n. 5
0
        /// <summary>
        /// Invokes this action with the given <paramref name="inParameters"/> synchronously.
        /// </summary>
        /// <param name="inParameters">Input parameters for the action invocation. Must match the formal input arguments.</param>
        /// <returns>List of output arguments of the called action.</returns>
        /// <exception cref="UPnPException">If an error occured during the action call.</exception>
        public IList <object> InvokeAction(IList <object> inParameters)
        {
            AsyncActionCallResult ar = (AsyncActionCallResult)BeginInvokeAction(inParameters, null, null);

            return(EndInvokeAction(ar));
        }
Esempio n. 6
0
 /// <summary>
 /// Invokes this action with the given <paramref name="inParameters"/> asynchronously.
 /// </summary>
 /// <remarks>
 /// This method will start the action call request asynchronously and will return immediately.
 /// The UPnP system invokes the provided <paramref name="callback"/> when the action result (or error message)
 /// returns. The call structure corresponds to the asynchronous call pattern used in the .net library.
 /// </remarks>
 /// <param name="inParameters">Input parameters for the action invocation. Must match the formal input arguments.
 /// Can be <c>null</c> if the parameter list is empty.</param>
 /// <param name="callback">Callback delegate to be invoked when the action result is present.</param>
 /// <param name="state">This object can be used to pass state information for the asynchronous operation.</param>
 /// <returns>Async result object which should be used as parameter for the <see cref="EndInvokeAction"/> method.</returns>
 public IAsyncResult BeginInvokeAction(IList<object> inParameters, AsyncCallback callback, object state)
 {
   if (_parentService == null)
     throw new IllegalCallException("Action '{0}' isn't assigned to a service", _name);
   if (!MatchesSignature(inParameters))
     throw new IllegalCallException("The given parameters don't match the formal input arguments of action '{0}'", _name);
   if (!IsConnected)
     throw new UPnPDisconnectedException("Action '{0}' isn't connected to a UPnP network action", _name);
   AsyncActionCallResult ar = new AsyncActionCallResult(callback, state);
   _connection.OnActionCalled(this, inParameters, ar);
   return ar;
 }