File tree Expand file tree Collapse file tree
whip/src/main/java/com/pedro/whip Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -229,7 +229,18 @@ class WhipClient(private val connectChecker: ConnectChecker) {
229229 Log .i(TAG , " found ${localCandidates.size} candidates" )
230230 val offerResponse = commandsManager.writeOffer()
231231 Log .i(TAG , offerResponse.body)
232-
232+ if (offerResponse.statusCode !in 200 .. 299 ) {
233+ if (offerResponse.statusCode == 401 || offerResponse.statusCode == 403 ) {
234+ onMainThread { connectChecker.onAuthError() }
235+ } else {
236+ onMainThread {
237+ connectChecker.onConnectionFailed(" Write offer failed: ${offerResponse.statusCode} " )
238+ }
239+ }
240+ return @launch
241+ } else if (commandsManager.authEnabled()) {
242+ onMainThread { connectChecker.onAuthSuccess() }
243+ }
233244
234245 val localFrag = commandsManager.localSdpInfo?.uFrag ? : return @launch
235246 val remoteFrag = commandsManager.remoteSdpInfo?.uFrag ? : return @launch
@@ -495,5 +506,4 @@ class WhipClient(private val connectChecker: ConnectChecker) {
495506 whipSender.resetBytesSend()
496507 }
497508
498-
499509}
Original file line number Diff line number Diff line change @@ -351,4 +351,6 @@ class CommandsManager {
351351 fun generateTransactionId (): ByteArray {
352352 return secureRandom.nextBytes(12 )
353353 }
354+
355+ fun authEnabled (): Boolean = token != null
354356}
You can’t perform that action at this time.
0 commit comments