Package 

Interface RpcManager

    • Method Detail

      • registerRpcMethod

         abstract Unit registerRpcMethod(String method, SuspendFunction1<RpcInvocationData, String> handler)

        Establishes the participant as a receiver for calls of the specified RPC method. Will overwrite any existing callback for the same method.

        Example:

        room.registerRpcMethod("greet") { (requestId, callerIdentity, payload, responseTimeout) ->
            Log.i("TAG", "Received greeting from ${callerIdentity}: ${payload}")
        
            // Return a string
            "Hello, ${callerIdentity}!"
        }

        The handler receives an RpcInvocationData with the following parameters:

        • requestId: A unique identifier for this RPC request

        • callerIdentity: The identity of the RemoteParticipant who initiated the RPC call

        • payload: The data sent by the caller (as a string)

        • responseTimeout: The maximum time available to return a response

        The handler should return a string. If unable to respond within RpcInvocationData.responseTimeout, the request will result in an error on the caller's side.

        You may throw errors of type RpcError with a string message in the handler, and they will be received on the caller's side with the message intact. Other errors thrown in your handler will not be transmitted as-is, and will instead arrive to the caller as 1500 ("Application Error").

        Parameters:
        method - The name of the indicated RPC method
        handler - Will be invoked when an RPC request for this method is received
      • unregisterRpcMethod

         abstract Unit unregisterRpcMethod(String method)

        Unregisters a previously registered RPC method.

        Parameters:
        method - The name of the RPC method to unregister
      • performRpc

         abstract String performRpc(Participant.Identity destinationIdentity, String method, String payload, Duration responseTimeout)

        Initiate an RPC call to a remote participant

        Parameters:
        destinationIdentity - The identity of the destination participant.
        method - The method name to call.
        payload - The payload to pass to the method.
        responseTimeout - Timeout for receiving a response after initial connection.