Class: RpcProxy

core.RpcProxy

Class representing a proxy for handling remote procedure calls (RPC) on a server with server.RpcSession as counter part.

Example: Invoke a remote function

RpcProxy {
    endpoint: "/::rpc"

    onInitialization: () =>
    {
        console.log("Invoking a remote function");
        invoke("remoteCall", [1, 2, 3])
        .then(result =>
        {
            console.log("Result: " + result);
        }
    }

}

It is possible to pass callback functions to a RPC call.

Example: Using callbacks

invoke("doSomething", progress =>
{
    console.log("Current progress: " + Math.round(progress * 100) + "%");
})
.then(result =>
{
    console.log("Result: " + result);
});

The RPC endpoint may return proxy objects for complex interfaces.

Example: Using a proxy object

invoke("getProxyInstance")
.then(async proxy =>
{
    const sum = await proxy.addRemote(1, 2);
    await proxy.countDown(n => console.log(n));
});

Values of type Uint8Array are transfered in binary form.

new core.RpcProxy ()

Properties:
Name Type Description
endpoint string

(default: "") The address of the RPC endpoint. Setting this to an empty string will close the connection cleanly.

status string

[readonly] The current connection status. One of disconnected|connecting|connected

Extends