Skip to content

Commit 7879153

Browse files
committed
Authenticate WebRTC using WAMP
1 parent 0dd606a commit 7879153

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

app/src/main/java/io/xconn/wampwebrtc/Helpers.kt

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.xconn.wampwebrtc
22

33
import io.xconn.wampproto.Joiner
4-
import io.xconn.wampproto.serializers.Serializer
54
import org.json.JSONObject
65

76
fun convertJsonToMap(jsonString: String): Map<String, Any> {
@@ -18,10 +17,9 @@ fun convertJsonToMap(jsonString: String): Map<String, Any> {
1817

1918
suspend fun join(
2019
peer: Peer,
21-
realm: String,
22-
serializer: Serializer,
20+
config: ClientConfig,
2321
): PeerBaseSession {
24-
val joiner = Joiner(realm, serializer)
22+
val joiner = Joiner(config.realm, config.serializer, config.authenticator)
2523
val hello = joiner.sendHello()
2624

2725
peer.send(hello as ByteArray)
@@ -32,7 +30,7 @@ suspend fun join(
3230

3331
if (toSend == null) {
3432
val sessionDetails = joiner.getSessionDetails()
35-
val base = PeerBaseSession(peer, sessionDetails, serializer)
33+
val base = PeerBaseSession(peer, sessionDetails, config.serializer)
3634
return base
3735
}
3836

app/src/main/java/io/xconn/wampwebrtc/Types.kt

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.xconn.wampwebrtc
22

33
import io.xconn.wampproto.SessionDetails
4+
import io.xconn.wampproto.auth.ClientAuthenticator
45
import io.xconn.wampproto.messages.Message
56
import io.xconn.wampproto.serializers.Serializer
67
import io.xconn.xconn.IBaseSession
@@ -59,6 +60,7 @@ data class ClientConfig(
5960
val serializer: Serializer,
6061
val subProtocol: String,
6162
val iceServers: List<IceServer>,
63+
val authenticator: ClientAuthenticator,
6264
)
6365

6466
data class OfferConfig(

app/src/main/java/io/xconn/wampwebrtc/WAMPSession.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class WAMPSession(
1313
val webRTCSession = webRTCConnection.connect(config)
1414

1515
val peer = WebRTCPeer(webRTCSession.channel, config.serializer, queue)
16-
val baseSession = join(peer, config.realm, config.serializer)
16+
val baseSession = join(peer, config)
1717

1818
return Session(baseSession)
1919
}

0 commit comments

Comments
 (0)