Example #1
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);
        }