File tree Expand file tree Collapse file tree
core/src/androidMain/kotlin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ import android.util.Log
1010import com.benasher44.uuid.Uuid
1111import kotlinx.coroutines.cancel
1212import kotlinx.coroutines.channels.awaitClose
13- import kotlinx.coroutines.channels.sendBlocking
13+ import kotlinx.coroutines.channels.onFailure
14+ import kotlinx.coroutines.channels.trySendBlocking
1415import kotlinx.coroutines.flow.Flow
1516import kotlinx.coroutines.flow.callbackFlow
1617
@@ -30,17 +31,16 @@ public class AndroidScanner internal constructor(private val filterServices: Lis
3031
3132 val callback = object : ScanCallback () {
3233 override fun onScanResult (callbackType : Int , result : ScanResult ) {
33- runCatching {
34- sendBlocking(Advertisement (result))
35- }.onFailure {
36- Log .w(TAG , " Unable to deliver scan result due to failure in flow or premature closing." )
37- }
34+ trySendBlocking(Advertisement (result))
35+ .onFailure {
36+ Log .w(TAG , " Unable to deliver scan result due to failure in flow or premature closing." )
37+ }
3838 }
3939
4040 override fun onBatchScanResults (results : MutableList <ScanResult >) {
4141 runCatching {
4242 results.forEach {
43- sendBlocking (Advertisement (it))
43+ trySendBlocking (Advertisement (it)).getOrThrow( )
4444 }
4545 }.onFailure {
4646 Log .w(TAG , " Unable to deliver batch scan results due to failure in flow or premature closing." )
You can’t perform that action at this time.
0 commit comments