Skip to content

Commit 069d58a

Browse files
committed
send delete on whip disconnect
1 parent 707a4a0 commit 069d58a

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

whip/src/main/java/com/pedro/whip/WhipClient.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,9 @@ class WhipClient(private val connectChecker: ConnectChecker) {
388388
dtlsConnection?.close()
389389
dtlsConnection = null
390390
val error = runCatching {
391-
//TODO write delete command
391+
withTimeoutOrNull(100.milliseconds) {
392+
commandsManager.writeDelete()
393+
}
392394
Log.i(TAG, "write delete success")
393395
}.exceptionOrNull()
394396
if (error != null) {

whip/src/main/java/com/pedro/whip/utils/Requests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ object Requests {
3939
val responseHeaders = mutableMapOf<String, String>()
4040
socket.headerFields.forEach {
4141
try {
42-
responseHeaders.put(it.key, it.value.joinToString(", "))
42+
responseHeaders[it.key] = it.value.joinToString(", ")
4343
} catch (_: Exception){}
4444
}
4545
val bodyResult = String(bytes)

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,22 @@ class CommandsManager {
193193
return answer
194194
}
195195

196+
fun writeDelete(): RequestResponse {
197+
val uri = "${if (tlsEnabled) "https" else "http"}://$host:$port/$path"
198+
val headers = mutableMapOf<String, String>().apply {
199+
if (!token.isNullOrEmpty()) put("Authorization", "Bearer $token")
200+
}
201+
return Requests.makeRequest(
202+
uri,
203+
"DELETE",
204+
headers,
205+
null,
206+
timeout,
207+
tlsEnabled,
208+
certificates
209+
)
210+
}
211+
196212
private suspend fun getStunCandidates(
197213
socketType: SocketType,
198214
stunHost: String,

0 commit comments

Comments
 (0)