Skip to content

Commit 7e23d24

Browse files
committed
fix delete session
1 parent 9b8689c commit 7e23d24

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

whip/src/main/java/com/pedro/whip/webrtc/CommandsManager.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class CommandsManager {
6060
var audioCodec = AudioCodec.OPUS
6161
private val timeout = 5000
6262
private var timeStamp = 0L
63+
private var sessionUrl: String? = null
6364
private val secureRandom = SecureRandom()
6465
val rtpTracks = RtpTracks()
6566
private var certificates: TrustManager? = null
@@ -127,6 +128,7 @@ class CommandsManager {
127128
vps = null
128129
remoteSdpInfo = null
129130
shouldSendAuth = false
131+
sessionUrl = null
130132
}
131133

132134
suspend fun gatheringCandidates(socketType: SocketType, timeout: Long, gatheringMode: GatheringMode): List<Candidate> {
@@ -187,13 +189,17 @@ class CommandsManager {
187189
if (answer.statusCode !in 200..299) return answer
188190
remoteSdpInfo = SdpParser.parseBodyAnswer(answer.body)
189191
tieBreak = secureRandom.nextBytes(8)
192+
sessionUrl = answer.headers.entries.firstOrNull { it.key.equals("location", true) }?.value
190193
Log.i(TAG, "remote info: $remoteSdpInfo")
191194
if (sendAuth) shouldSendAuth = true
192195
return answer
193196
}
194197

195198
fun writeDelete(): RequestResponse {
196-
val uri = "${if (tlsEnabled) "https" else "http"}://$host:$port/$path"
199+
val uri = sessionUrl?.let {
200+
if (it.startsWith("http", true)) it
201+
else "${if (tlsEnabled) "https" else "http"}://$host:$port/${it.removePrefix("/")}"
202+
} ?: "${if (tlsEnabled) "https" else "http"}://$host:$port/$path"
197203
val headers = mutableMapOf<String, String>().apply {
198204
if (!token.isNullOrEmpty() && shouldSendAuth) put("Authorization", "Bearer $token")
199205
}

0 commit comments

Comments
 (0)