commit
de728f6c36
@ -25,6 +25,7 @@ Bugfix 🐛:
|
|||||||
- Failed to build unique file (#1954)
|
- Failed to build unique file (#1954)
|
||||||
- Highlighted Event when opening a permalink from another room (#1033)
|
- Highlighted Event when opening a permalink from another room (#1033)
|
||||||
- A Kick appears has "someone has made no change" (#1959)
|
- A Kick appears has "someone has made no change" (#1959)
|
||||||
|
- Renew turnserver credentials when ttl runs out
|
||||||
|
|
||||||
Translations 🗣:
|
Translations 🗣:
|
||||||
- Add PlayStore description resources in the Triple-T format, to let Weblate handle them
|
- Add PlayStore description resources in the Triple-T format, to let Weblate handle them
|
||||||
|
@ -58,18 +58,32 @@ internal class DefaultCallSignalingService @Inject constructor(
|
|||||||
|
|
||||||
private val activeCalls = mutableListOf<MxCall>()
|
private val activeCalls = mutableListOf<MxCall>()
|
||||||
|
|
||||||
private var cachedTurnServerResponse: TurnServerResponse? = null
|
private val cachedTurnServerResponse = object {
|
||||||
|
|
||||||
|
private val MIN_TTL = 60
|
||||||
|
|
||||||
|
private val now = { System.currentTimeMillis() / 1000 }
|
||||||
|
|
||||||
|
private var expiresAt: Long = 0
|
||||||
|
|
||||||
|
var data: TurnServerResponse? = null
|
||||||
|
get() = if (expiresAt > now()) field else null
|
||||||
|
set(value) {
|
||||||
|
expiresAt = now() + (value?.ttl ?: 0) - MIN_TTL
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun getTurnServer(callback: MatrixCallback<TurnServerResponse>): Cancelable {
|
override fun getTurnServer(callback: MatrixCallback<TurnServerResponse>): Cancelable {
|
||||||
if (cachedTurnServerResponse != null) {
|
if (cachedTurnServerResponse.data != null) {
|
||||||
cachedTurnServerResponse?.let { callback.onSuccess(it) }
|
cachedTurnServerResponse.data?.let { callback.onSuccess(it) }
|
||||||
return NoOpCancellable
|
return NoOpCancellable
|
||||||
}
|
}
|
||||||
return turnServerTask
|
return turnServerTask
|
||||||
.configureWith(GetTurnServerTask.Params) {
|
.configureWith(GetTurnServerTask.Params) {
|
||||||
this.callback = object : MatrixCallback<TurnServerResponse> {
|
this.callback = object : MatrixCallback<TurnServerResponse> {
|
||||||
override fun onSuccess(data: TurnServerResponse) {
|
override fun onSuccess(data: TurnServerResponse) {
|
||||||
cachedTurnServerResponse = data
|
cachedTurnServerResponse.data = data
|
||||||
callback.onSuccess(data)
|
callback.onSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user