asWebsocketConnection

suspend fun HttpClient.asWebsocketConnection(baseUrl: String, env: KsrpcEnvironment<String>): Connection<String>

Turn an HttpClient into a websocket based Connection for a specified baseUrl.

This is functionally equivalent to baseUrl.toKsrpcUri().connect(env).

Samples

val env = ksrpcEnvironment { }

val httpClient = HttpClient {
    install(WebSockets)
}

// Create a bidirectional WebSocket connection.
val connection = httpClient.asWebsocketConnection(
    "ws://localhost:8080/ws",
    env
)

// Use connect<Host, Client> to set up both directions at once,
// or use defaultChannel() for client-only access.
val stub = connection.defaultChannel().toStub<GreetingService, String>()
val greeting = stub.greet("world")