Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authenticate WebRTC using WAMP #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions app/src/main/java/io/xconn/wampwebrtc/Helpers.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.xconn.wampwebrtc

import io.xconn.wampproto.Joiner
import io.xconn.wampproto.serializers.Serializer
import org.json.JSONObject

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

suspend fun join(
peer: Peer,
realm: String,
serializer: Serializer,
config: ClientConfig,
): PeerBaseSession {
val joiner = Joiner(realm, serializer)
val joiner = Joiner(config.realm, config.serializer, config.authenticator)
val hello = joiner.sendHello()

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

if (toSend == null) {
val sessionDetails = joiner.getSessionDetails()
val base = PeerBaseSession(peer, sessionDetails, serializer)
val base = PeerBaseSession(peer, sessionDetails, config.serializer)
return base
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/io/xconn/wampwebrtc/Types.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.xconn.wampwebrtc

import io.xconn.wampproto.SessionDetails
import io.xconn.wampproto.auth.ClientAuthenticator
import io.xconn.wampproto.messages.Message
import io.xconn.wampproto.serializers.Serializer
import io.xconn.xconn.IBaseSession
Expand Down Expand Up @@ -59,6 +60,7 @@ data class ClientConfig(
val serializer: Serializer,
val subProtocol: String,
val iceServers: List<IceServer>,
val authenticator: ClientAuthenticator,
)

data class OfferConfig(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/xconn/wampwebrtc/WAMPSession.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class WAMPSession(
val webRTCSession = webRTCConnection.connect(config)

val peer = WebRTCPeer(webRTCSession.channel, config.serializer, queue)
val baseSession = join(peer, config.realm, config.serializer)
val baseSession = join(peer, config)

return Session(baseSession)
}
Expand Down
Loading