Clear Up
SharpKit Reference

RemotingProvider Class

The RemotingProvider exposes access to server side methods on the client (a remote procedure call (RPC) type of connection where the client can initiate a procedure on the server).

This allows for code to be organized in a fashion that is maintainable, while providing a clear path between client and server, something that is not always apparent when using URLs.

To accomplish this the server-side needs to describe what classes and methods are available on the client-side. This configuration will typically be outputted by the server-side Ext.Direct stack when the API description is built.

Namespace: Ext.direct

Base Interfaces

Fields

Name Description
actions Object literal defining the server side actions and methods. For example, if the Provider is configured with:
"actions":{ // each property within the 'actions' object represents a server side Class
            "TestAction":[ // array of methods within each server side Class to be
            {              // stubbed out on client
            "name":"doEcho",
            "len":1
            },{
            "name":"multiply",// name of method
            "len":2           // The number of parameters that will be used to create an
            // array of data to send to the server side function.
            // Ensure the server sends back a Number, not a String.
            },{
            "name":"doForm",
            "formHandler":true, // direct the client to use specialized form handling method
            "len":1
            }]
            }
            
Note that a Store is not required, a server method can be called at any time. In the following example a client side handler is used to call the server side method "multiply" in the server-side "TestAction" Class:
TestAction.multiply(
            2, 4, // pass two arguments to server, so specify len=2
            // callback function after the server is called
            // result: the result returned by the server
            //      e: Ext.direct.RemotingEvent object
            function(result, e){
            var t = e.getTransaction();
            var action = t.action; // server side Class called
            var method = t.method; // server side method called
            if(e.status){
            var answer = Ext.encode(result); // 8
            }else{
            var msg = e.message; // failure message
            }
            }
            );
            
In the example above, the server side "multiply" function will be passed two arguments (2 and 4). The "multiply" method should return the value 8 which will be available as the result in the example above.
enableBuffer true or false to enable or disable combining of method calls. If a number is specified this is the amount of time in milliseconds to wait before sending a batched request. Calls which are received within the specified timeframe will be

concatenated together and sent in a single request, optimizing the application by reducing the amount of round trips that have to be made to the server.

Defaults to: 10
enableUrlEncode Specify which param will hold the arguments for the method. Defaults to 'data'.
maxRetries Number of times to re-attempt delivery on failure of a call. Defaults to: 1
namespace Namespace for the Remoting Provider (defaults to the browser global scope of window). Explicitly specify the namespace Object, or specify a String to have a namespace created implicitly.
timeout The timeout to use for each request.
url Required. The url to connect to the Ext.direct.Manager server-side router.
© Copyright 2005-2011 SharpKit. All rights reserved.