For some reason, I am implementing a simple RPC framework on KotlinNative.
I need to implement interface on runtime. Below is my Code.
interface RpcProtocol {
}
open class UdpClient<T : RpcProtocol> {
fun call(host: String, port: Int): T {
// implement T dynamically
}
}
// I can use it like this
interface Kademlia : RpcProtocol {
fun ping(node: Node): Node
fun store(node: Node)
fun findNode() {}
fun findValue() {}
}
fun main() {
val client : UdpClient<Kademlia> = UdpClient()
val node = client.call("123", 1)
.ping(Node(Id.createByPow(2), "123", 1))
}
Can anyone help me, than very much