feat: Cleans up some of the shutdown logic so that the MQTTClient is disconnected properly.

This commit is contained in:
2024-11-12 22:19:09 -05:00
parent fbbd65f7ae
commit efd9907b4a
4 changed files with 8 additions and 12 deletions

View File

@@ -10,7 +10,7 @@ public extension MQTTConnectionManager {
logger: Logger? = nil
) -> Self {
let manager = ConnectionManager(client: client, logger: logger)
return .init { _ in
return .init {
try await manager.connect(cleanSession: cleanSession)
return manager.stream
@@ -76,6 +76,8 @@ private actor ConnectionManager {
nonisolated func shutdown() {
client.logger.trace("Shutting down connection.")
client.removeCloseListener(named: name)
client.removeShutdownListener(named: name)
continuation.yield(.shuttingDown)
continuation.finish()
}