davidliu
Committed by GitHub

debounce negotiations with a timer of 0.1s to fix failing connect (#13)

... ... @@ -68,7 +68,14 @@ constructor(
return result
}
val negotiate = debounce<Unit, Unit>(100, coroutineScope) { createAndSendOffer() }
val negotiate = debounce<MediaConstraints?, Unit>(100, coroutineScope) {
if (it != null) {
createAndSendOffer(it)
} else {
createAndSendOffer()
}
}
suspend fun createAndSendOffer(constraints: MediaConstraints = MediaConstraints()) {
if (listener == null) {
return
... ...
... ... @@ -272,7 +272,7 @@ internal constructor(
subscriber.prepareForIceRestart()
// only restart publisher if it's needed
if (hasPublished) {
publisher.createAndSendOffer(
publisher.negotiate(
getPublisherOfferConstraints().apply {
with(mandatory){
add(
... ... @@ -294,7 +294,7 @@ internal constructor(
return
}
coroutineScope.launch {
publisher.createAndSendOffer(getPublisherOfferConstraints())
publisher.negotiate(getPublisherOfferConstraints())
}
}
... ...