<rpc>
remote procedure call

JavaScript: lz.rpc
extends <node> » lz.Eventable »

The <rpc> tag is the abstract base class for RPC classes. Subclasses must implement the load() method, which is responsible for creating the proxy object. The proxy object contains a set of function stubs that invoke a remote function (or procedure) over the network. It's up to the caller of the stub function to know what parameters need to be passed in by looking at what the backend remote function expects. If calling a JavaRemoting (<javarpc>) function, looking at the associated Java API will be necessary. If calling a SOAP (<soap>) function, the developer will need to look at the corresponding operation in a WSDL file.

The implementation of this class can be found in lps/components/rpc/rpc.lzx. For details, see the RPC chapter of the Developer's Guide.

Objects derived from rpc use function stubs in the proxy object to invoke a remote function. Each function stub expects an array of arguments and a delegate to deal with the return value, respectively. Both the array and the delegate are required. If a function has no arguments, rpc passes in an empty array.

Example 81. Invoking remote function using proxy function stub

<canvas debug="true" height="280">
    
        <debug x="10" y="40" width="470" height="230"/>
    
        <soap name="temperature" autoload="false" wsdl="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter">
            <method name="init">
                super.init();
                Debug.debug('soap service loading...');
                this.load();
            </method>
        <handler name="onload">
            Debug.debug('temperature service loaded!');
            Debug.debug('---');
    
            // don't allow others to call RPC object until proxy is loaded.
            canvas.convert.setAttribute('visible', true);
            </handler>   
            </soap> 
            <button name="convert" text="convert" x="10" y="10" visible="false">      
            <attribute name="myDel" value="$once{new LzDelegate(this, 'myhandler')}"/>       
            <handler name="onclick">
            var f = 100;
            canvas.temperature.proxy.FtoC([ f ], this.myDel)
            Debug.debug('Invoking FtoC...');
        </handler>
        <method name="myhandler" args="data">
            Debug.debug('got data: %w', data);
        </method>
    
        </button>
    
    </canvas>

Alternatively, you can use remotecall for a more declarative approach to invoking functions. See the <remotecall> reference or the RPC chapter of the Developer's Guide for more information.

Example 82. Invoking remote function using remotecall

<canvas debug="true" height="280">
    
        <debug x="10" y="40" width="470" height="230"/>
    
        <soap name="temperature" autoload="false" wsdl="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter">
    
        <method name="init">
            super.init();
            Debug.debug('soap service loading...');
            this.load();
        </method>
    
        <handler name="onload">
            Debug.debug('temperature service loaded!');
            Debug.debug('---');
    
            // don't allow others to call RPC object until proxy is loaded.
            canvas.convert.setAttribute('visible', true);
        </handler>
    
        <remotecall funcname="FtoC">
        <param value="100"/>
    
            <handler name="ondata" args="value">
                Debug.debug('got data: %w', value);
                </handler>
                <handler name="onerror" args="errmsg">
                Debug.debug('error: %w', errmsg);
            </handler>
    
        </remotecall>
    
    </soap>
    
    <button name="convert" text="convert" x="10" y="10" visible="false">
        <handler name="onclick">
            canvas.temperature.FtoC.invoke();
        Debug.debug('Invoking FtoC...');
        </handler>
    </button>
    
    </canvas>

See Also:

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
autoload boolean boolean true read/write
  Load remote object during init. If false, create remote object by calling load(). Default is true.
proxy expression any null readonly
  The remote proxy object. Proxy is set after the rpc object loads. Proxy contains client-side function stubs to remote methods. Each method takes an array of arguments and a delegate like: myrpc.proxy.remoteFunc( [ p1, p2, ..., pN ], delegate ); Remote methods with no arguments are passed in an empty array like: myrpc.proxy.otherRemoteFunc( [], delegate ); The delegate is used to handle the return value since RPC calls are asynchronous.
proxyinfo expression any null read/write
   
secure boolean boolean false read/write
  Make connection secure between client and the LPS secure (HTTPS). Default is false.
secureport number Number null read/write
  The port to use for the secure socket between the client and the LPS. If secure is false, this value is ignored.

Methods

load()
rpc.load();
ABSTRACT: method to load the remote object interface.

makeProxyStubFunction()
rpc.makeProxyStubFunction(fn);
Parameter Name Type Description
fn    

unload()
rpc.unload();
Interface to unload proxy stub. Default is to null proxy.

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
ondata This event is triggered when declared inner calls do not handle their ondata events.
onerror This event is triggered when an error or timeout occurs associated with getting this object or calling one of its remote methods.
onload This event is triggered when the remote object is loaded.
onunload This event is triggered when the remote object is unloaded.

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy