-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
featureNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
Can KtorRpcClient registerService, KrpcRoute withService, i.e. Server call Client defined Service?
Describe the solution you'd like
In KrpcClient:
val rpcClient = client.rpc {
url("ws://localhost:8080/rpc")
rpcConfig { serialization { json() } }
}
rpcClient.registerService<ClientService> { ClientServiceImpl() }
In KrpcServer:
routing {
rpc("/rpc") {
rpcConfig { serialization { json() } }
// 获取客户端注册的 Service
val clientService = withService<ClientService>()
// 服务器调用客户端的 Service 方法
val response = clientService.notify("Hello from server!")
println("Client responded: $response")
}
}
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request