CommunicationsServiceHandler

interface CommunicationsServiceHandler

Interface for service handlers.

Generated service stub instances provide a CommunicationsServiceHandler, which when called will call the appropriate function on the stub instance. The service handler can be obtained by calling stub.toServiceHandler().

When initializing a generated service client proxy instance a CommunicationsServiceHandler should be provided. All calls into the client proxy will cause a call into the provided service handler. The service handler can then generate the appropriate protocol messages for those calls.

There are two kinds of remote calls. A simple function call, which only returns once. And a streaming function call that can return multiple values.

Functions

Link copied to clipboard
abstract suspend fun callFunction(methodId: Int, message: ByteString): ByteString

When called by the generated service client proxy implementation it calls the remote method with the specified methodId and the specified message as method call arguments. A ByteString should be returned as return value for the method call. If the remote call cannot be completed it fails by throwing a CancellationException.

Link copied to clipboard
abstract suspend fun callStreamingFunction(    methodId: Int,     message: ByteString = ByteString.EMPTY,     resultCallback: (result: ByteString) -> Unit)

When called by generated service client proxy implementations, it calls the remote streaming method with the specified methodId and the specified message as method call arguments. Multiple results can be returned by calling the specified resultCallback zero or more times. If the remote call cannot be completed or is canceled (e.g. by disconnection) it fails by throwing a CancellationException.