@@ -11,30 +11,27 @@ import io.ktor.websocket.Frame
11
11
import io.ktor.websocket.readBytes
12
12
import io.ktor.websocket.readText
13
13
import io.xconn.wampproto.Joiner
14
- import io.xconn.wampproto.auth.AnonymousAuthenticator
15
- import io.xconn.wampproto.auth.ClientAuthenticator
16
- import io.xconn.wampproto.serializers.JSONSerializer
17
- import io.xconn.wampproto.serializers.Serializer
18
14
import kotlinx.coroutines.CompletableDeferred
19
15
import kotlinx.coroutines.async
20
16
import kotlinx.coroutines.coroutineScope
21
17
22
18
class WAMPSessionJoiner (
23
- private val authenticator : ClientAuthenticator = AnonymousAuthenticator (""),
24
- private val serializer : Serializer = JSONSerializer (),
19
+ private val config : ClientConfig ,
25
20
) {
26
- private val subProtocol = getSubProtocol(serializer)
21
+ private val subProtocol = getSubProtocol(config. serializer)
27
22
private val client =
28
23
HttpClient (CIO ) {
29
- install(WebSockets )
24
+ install(WebSockets ) {
25
+ pingInterval = config.keepAliveInterval
26
+ }
30
27
defaultRequest {
31
28
header(" Sec-WebSocket-Protocol" , subProtocol)
32
29
}
33
30
}
34
31
35
32
suspend fun join (url : String , realm : String ): BaseSession {
36
33
val welcomeCompleter = CompletableDeferred <BaseSession >()
37
- val joiner = Joiner (realm, serializer, authenticator)
34
+ val joiner = Joiner (realm, config. serializer, config. authenticator)
38
35
39
36
val session = client.webSocketSession(url)
40
37
@@ -51,7 +48,7 @@ class WAMPSessionJoiner(
51
48
52
49
if (toSend == null ) {
53
50
// Complete handshake and session creation
54
- welcomeCompleter.complete(BaseSession (session, joiner.getSessionDetails(), serializer))
51
+ welcomeCompleter.complete(BaseSession (session, joiner.getSessionDetails(), config. serializer))
55
52
break
56
53
} else {
57
54
session.sendFrame(toSend)
0 commit comments