createServiceWorkerWithConnection
expect fun createServiceWorkerWithConnection(workerScriptPath: String, env: KsrpcEnvironment<String>): Connection<String>
Creates a connection to a service worker registered at workerScriptPath.
This is an experimental API — the service-worker transport has limited test coverage and its behavior may change without notice. Opt in explicitly with @OptIn(ExperimentalKsrpc::class).
actual fun createServiceWorkerWithConnection(workerScriptPath: String, env: KsrpcEnvironment<String>): Connection<String>
Creates a connection to a service worker registered at workerScriptPath.
Samples
import com.monkopedia.ksrpc.annotation.ExperimentalKsrpc
import com.monkopedia.ksrpc.channels.registerDefault
import com.monkopedia.ksrpc.ksrpcEnvironment
import com.monkopedia.ksrpc.serialized
import com.monkopedia.ksrpc.toStub
import com.monkopedia.ksrpc.webworker.createServiceWorkerWithConnection
import com.monkopedia.ksrpc.webworker.onServiceWorkerConnection
fun main() {
//sampleStart
val env = ksrpcEnvironment { }
val connection = createServiceWorkerWithConnection("/worker.js", env)
val service = connection.defaultChannel().toStub<GreetingService, String>()
//sampleEnd
}actual fun createServiceWorkerWithConnection(workerScriptPath: String, env: KsrpcEnvironment<String>): Connection<String>