Exemplo n.º 1
0
    /// <summary>
    /// Executes a WebOperation with the given criteria.
    /// </summary>
    /// <param name="criteria">Criteria that specifies how to invoke the operation.</param>
    /// <returns>A WWW object containing the results of the operation.</returns>
    public static ResultSet Execute(WebOperationCriteria criteria)
    {
        Asserter.NotNull(criteria, "WebOperation.Execute:criteria is null");

        if (_webOperation == null)
        {
            _webOperation = new WebOperation();
        }

        return(_webOperation.ExecuteOperation(criteria));
    }
Exemplo n.º 2
0
    /// <summary>
    /// Executes a WebOperation with the given criteria asynchronously. Upon completion, the given WebOperationCallback is invoked with the results of the operation.
    /// </summary>
    /// <param name="criteria">Criteria that specifies how to invoke the operation.</param>
    /// <param name="callback">The callback to be invoked upon completion of the operation.</param>
    public static void ExecuteAsync(WebOperationCriteria criteria, WebOperationCallback webOperationCallback)
    {
        Asserter.NotNull(criteria, "WebOperation.ExecuteAsync:criteria is null");
        Asserter.NotNull(webOperationCallback, "WebOpreation.ExecuteAsync:webOperationCallback");

        if (_webOperation == null)
        {
            _webOperation = new WebOperation();
        }

        _webOperation.ExecuteOperationAsync(criteria, webOperationCallback);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Executes the web operation asynchronously from the given WebOperationCriteria, and invokes the given WebOperationCallback upon completion.
    /// </summary>
    /// <param name="criteria">The criteria containing the data that governs the action of this operation.</param>
    /// <param name="callback">The callback to be invoked upon completion of the operation.</param>
    private void ExecuteOperationAsync(WebOperationCriteria criteria, WebOperationCallback callback)
    {
        WWWForm form = new WWWForm();

        foreach (KeyValuePair <string, string> pair in criteria.Fields)
        {
            form.AddField(pair.Key, pair.Value);
        }

        WWW www = new WWW(criteria.URL, form);

        _coroutineRunner.StartCoroutine(WaitForWWW(www, callback));
    }
Exemplo n.º 4
0
    /// <summary>
    /// Executes the web operation from the given WebOperationCriteria.
    /// </summary>
    /// <param name="criteria">The criteria containing the data that governs the action of this operation.</param>
    /// <returns></returns>
    private ResultSet ExecuteOperation(WebOperationCriteria criteria)
    {
        WWWForm form = new WWWForm();

        foreach (KeyValuePair <string, string> pair in criteria.Fields)
        {
            form.AddField(pair.Key, pair.Value);
        }

        WWW www = new WWW(criteria.URL, form);

        while (!www.isDone)
        {
        }
        return(ParseResponse(www));
    }