diff --git a/src/commonMain/kotlin/net.sergeych.superlogin/client/SuperloginClient.kt b/src/commonMain/kotlin/net.sergeych.superlogin/client/SuperloginClient.kt index 9a16635..bc9c373 100644 --- a/src/commonMain/kotlin/net.sergeych.superlogin/client/SuperloginClient.kt +++ b/src/commonMain/kotlin/net.sergeych.superlogin/client/SuperloginClient.kt @@ -354,7 +354,7 @@ class SuperloginClient( companion object { - inline operator fun invoke( + inline operator fun invoke( t: Parsec3Transport, savedData: SuperloginData? = null, ): SuperloginClient { diff --git a/src/jvmMain/kotlin/net/sergeych/superlogin/server/SuperloginServer.kt b/src/jvmMain/kotlin/net/sergeych/superlogin/server/SuperloginServer.kt index ff37f51..b8be6e0 100644 --- a/src/jvmMain/kotlin/net/sergeych/superlogin/server/SuperloginServer.kt +++ b/src/jvmMain/kotlin/net/sergeych/superlogin/server/SuperloginServer.kt @@ -10,7 +10,10 @@ import kotlin.random.Random fun randomACOLike(): ByteArray { return Random.nextBytes(117) } -inline fun , H : CommandHost> AdapterBuilder.superloginServer() { +inline fun , H : CommandHost> AdapterBuilder.superloginServer( + crossinline sessionBuilder: suspend ()->T +) { + newSession { sessionBuilder() } addErrors(SuperloginExceptionsRegistry) val a2 = SuperloginServerApi() on(a2.slGetNonce) { nonce } diff --git a/src/jvmTest/kotlin/net/sergeych/WsServerKtTest.kt b/src/jvmTest/kotlin/net/sergeych/WsServerKtTest.kt index e187a2b..69b18fd 100644 --- a/src/jvmTest/kotlin/net/sergeych/WsServerKtTest.kt +++ b/src/jvmTest/kotlin/net/sergeych/WsServerKtTest.kt @@ -154,15 +154,17 @@ internal class WsServerKtTest { } + class S1: WithAdapter() + @Test fun changePasswordTest() { embeddedServer(Netty, port = 8081, module = Application::testServerModule).start(wait = false) runBlocking { - val client = Parsec3WSClient("ws://localhost:8081/api/p3") + val client = Parsec3WSClient.withSession("ws://localhost:8081/api/p3") val api = TestApiServer() - val slc = SuperloginClient(client) + val slc = SuperloginClient(client) assertEquals(LoginState.LoggedOut, slc.state.value) var rt = slc.register("foo", "passwd", TestData("bar!")) assertIs(rt) @@ -211,10 +213,9 @@ internal class WsServerKtTest { } fun Application.testServerModule() { - parsec3TransportServer(TestApiServer>()) { + parsec3TransportServer(TestApiServer()) { // superloginServer(TestServerTraits,TestApiServer>()) { - newSession { TestSession() } - superloginServer() + superloginServer { TestSession() } on(api.loginName) { println("login name called. now we have $currentLoginName : $superloginData") currentLoginName