Class JsonRpcProxyFactory<T>

Deprecated

since 1.39.0 use RpcProxyFactory instead

Type Parameters

  • T extends object

Hierarchy (view full)

Constructors

Properties

onDidCloseConnectionEmitter: Emitter<void> = ...
onDidOpenConnectionEmitter: Emitter<void> = ...
rpcDeferred: Deferred<RpcProtocol>
rpcProtocolFactory: RpcProtocolFactory = defaultRpcProtocolFactory
target?: any

The object to expose to RPC methods calls. If this is omitted, the proxy won't be able to handle requests, only send them.

Methods

  • Get a callable object that executes a RPC method call.

    Getting a property on the Proxy object returns a callable that, when called, executes a RPC call. The name of the property defines the method to be called. The callable takes a variable number of arguments, which are passed in the RPC method call.

    For example, if you have a Proxy object:

    let fooProxyFactory = RpcProxyFactory<Foo>('/foo')
    let fooProxy = fooProxyFactory.createProxy()

    accessing fooProxy.bar will return a callable that, when called, executes a RPC method call to method bar. Therefore, doing fooProxy.bar() will call the bar method on the remote Foo object.

    Parameters

    • target: T

      unused.

    • p: PropertyKey

      The property accessed on the Proxy object.

    • receiver: any

      unused.

    Returns any

    A callable that executes the RPC call.

  • Process an incoming RPC method call.

    onRequest is called when the RPC connection received a method call request. It calls the corresponding method on [[target]].

    The return value is a Promise object that is resolved with the return value of the method call, if it is successful. The promise is rejected if the called method does not exist or if it throws.

    Parameters

    • method: string
    • Rest ...args: any[]

    Returns Promise<any>

    A promise of the method call completion.