Skip to content
Snippets Groups Projects
Commit 9fa3d003 authored by Davide Pianca's avatar Davide Pianca
Browse files

Add exception handler parameter to MQTTClient.runSuspend

parent be361045
No related branches found
No related tags found
No related merge requests found
......@@ -60,6 +60,7 @@ import io.github.davidepianca98.socket.SocketClosedException
import io.github.davidepianca98.socket.SocketInterface
import io.github.davidepianca98.socket.streams.EOFException
import io.github.davidepianca98.socket.tls.TLSClientSettings
import kotlinx.coroutines.CoroutineExceptionHandler
/**
* MQTT 3.1.1 and 5 client
......@@ -480,9 +481,13 @@ public class MQTTClient(
* Run the client
* This function runs the thread on the specified dispatcher until the client stops
* @param dispatcher the dispatcher on which to run the client
* @param exceptionHandler the exception handler for the coroutine scope
*/
public fun runSuspend(dispatcher: CoroutineDispatcher = Dispatchers.Default) {
CoroutineScope(dispatcher).launch {
public fun runSuspend(
dispatcher: CoroutineDispatcher = Dispatchers.Default,
exceptionHandler: CoroutineExceptionHandler = CoroutineExceptionHandler { _, throwable ->}
) {
CoroutineScope(dispatcher).launch(exceptionHandler) {
run()
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment