Skip to content
Snippets Groups Projects
Commit 20649e9b authored by NB Grey's avatar NB Grey
Browse files

Normalization of disconnection

parent 13e66b42
No related branches found
No related tags found
No related merge requests found
...@@ -61,7 +61,6 @@ import io.github.davidepianca98.socket.SocketClosedException ...@@ -61,7 +61,6 @@ import io.github.davidepianca98.socket.SocketClosedException
import io.github.davidepianca98.socket.SocketInterface import io.github.davidepianca98.socket.SocketInterface
import io.github.davidepianca98.socket.streams.EOFException import io.github.davidepianca98.socket.streams.EOFException
import io.github.davidepianca98.socket.tls.TLSClientSettings import io.github.davidepianca98.socket.tls.TLSClientSettings
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.yield import kotlinx.coroutines.yield
...@@ -423,7 +422,6 @@ public class MQTTClient( ...@@ -423,7 +422,6 @@ public class MQTTClient(
} catch (e: MQTTException) { } catch (e: MQTTException) {
lastException = e lastException = e
disconnect(e.reasonCode) disconnect(e.reasonCode)
close()
onDisconnected(null) onDisconnected(null)
throw e throw e
} catch (e: EOFException) { } catch (e: EOFException) {
...@@ -434,13 +432,11 @@ public class MQTTClient( ...@@ -434,13 +432,11 @@ public class MQTTClient(
} catch (e: IOException) { } catch (e: IOException) {
lastException = e lastException = e
disconnect(ReasonCode.UNSPECIFIED_ERROR) disconnect(ReasonCode.UNSPECIFIED_ERROR)
close()
onDisconnected(null) onDisconnected(null)
throw e throw e
} catch (e: Exception) { } catch (e: Exception) {
lastException = e lastException = e
disconnect(ReasonCode.IMPLEMENTATION_SPECIFIC_ERROR) disconnect(ReasonCode.IMPLEMENTATION_SPECIFIC_ERROR)
close()
onDisconnected(null) onDisconnected(null)
throw e throw e
} }
...@@ -529,10 +525,10 @@ public class MQTTClient( ...@@ -529,10 +525,10 @@ public class MQTTClient(
step() step()
yield() yield()
} }
} catch (e: CancellationException) { } finally {
if (running.value) {
disconnect(ReasonCode.IMPLEMENTATION_SPECIFIC_ERROR) disconnect(ReasonCode.IMPLEMENTATION_SPECIFIC_ERROR)
close() }
throw e
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment