KrpcServer

abstract class KrpcServer(config: KrpcConfig.Server, transport: KrpcTransport) : RpcServer, KrpcEndpoint(source)

kRPC implementation of the RpcServer. Takes care of tracking requests and responses, serializing data, tracking streams, processing exceptions, and other protocol responsibilities. Routes resulting messages to the proper registered services. Leaves out the delivery of encoded messages to the specific implementations with KrpcTransport.

Parameters

config

configuration provided for that specific server. Applied to all services that use this server.

transport

KrpcTransport instance that will be used to send and receive RPC messages. IMPORTANT: Must be exclusive to this server, otherwise unexpected behavior may occur.

Constructors

Link copied to clipboard
constructor(config: KrpcConfig.Server, transport: KrpcTransport)

Functions

Link copied to clipboard
suspend fun awaitCompletion()

Waits until the server is closed.

Link copied to clipboard
fun close(message: String? = null)

Close this server, removing all the services and stopping accepting messages.

Link copied to clipboard
open override fun <Service : Any> deregisterService(serviceKClass: KClass<Service>)
Link copied to clipboard
override fun <Service : Any> registerService(serviceKClass: KClass<Service>, serviceFactory: () -> Service)