|
14 | 14 | import Atomics |
15 | 15 | import Dispatch |
16 | 16 | import Logging |
| 17 | +import NIO |
| 18 | +import NIOConcurrencyHelpers |
| 19 | +import NIOTransportServices |
| 20 | + |
17 | 21 | #if canImport(Network) |
18 | 22 | import Network |
19 | 23 | #endif |
20 | | -import NIO |
21 | | -import NIOConcurrencyHelpers |
22 | | -#if canImport(NIOSSL) |
| 24 | +#if os(macOS) || os(Linux) |
23 | 25 | import NIOSSL |
24 | 26 | #endif |
25 | | -import NIOTransportServices |
26 | 27 |
|
27 | 28 | /// Swift NIO MQTT Client |
28 | 29 | /// |
@@ -180,11 +181,13 @@ public final class MQTTClient { |
180 | 181 | /// - Throws: MQTTError.alreadyShutdown: You have already shutdown the client |
181 | 182 | public func syncShutdownGracefully() throws { |
182 | 183 | if let eventLoop = MultiThreadedEventLoopGroup.currentEventLoop { |
183 | | - preconditionFailure(""" |
184 | | - BUG DETECTED: syncShutdown() must not be called when on an EventLoop. |
185 | | - Calling syncShutdown() on any EventLoop can lead to deadlocks. |
186 | | - Current eventLoop: \(eventLoop) |
187 | | - """) |
| 184 | + preconditionFailure( |
| 185 | + """ |
| 186 | + BUG DETECTED: syncShutdown() must not be called when on an EventLoop. |
| 187 | + Calling syncShutdown() on any EventLoop can lead to deadlocks. |
| 188 | + Current eventLoop: \(eventLoop) |
| 189 | + """ |
| 190 | + ) |
188 | 191 | } |
189 | 192 | let errorStorageLock = NIOLock() |
190 | 193 | var errorStorage: Error? |
@@ -403,12 +406,12 @@ public final class MQTTClient { |
403 | 406 | /// Disconnect from server |
404 | 407 | /// - Returns: Future waiting on disconnect message to be sent |
405 | 408 | public func disconnect() -> EventLoopFuture<Void> { |
406 | | - return self.disconnect(packet: MQTTDisconnectPacket()) |
| 409 | + self.disconnect(packet: MQTTDisconnectPacket()) |
407 | 410 | } |
408 | 411 |
|
409 | 412 | /// Return if client has an active connection to broker |
410 | 413 | public func isActive() -> Bool { |
411 | | - return self.connection?.channel.isActive ?? false |
| 414 | + self.connection?.channel.isActive ?? false |
412 | 415 | } |
413 | 416 |
|
414 | 417 | /// Add named publish listener. Called whenever a PUBLISH message is received from the server |
@@ -530,7 +533,7 @@ extension MQTTClient { |
530 | 533 | func resendOnRestart() { |
531 | 534 | let inflight = self.inflight.packets |
532 | 535 | self.inflight.clear() |
533 | | - inflight.forEach { packet in |
| 536 | + for packet in inflight { |
534 | 537 | switch packet { |
535 | 538 | case let publish as MQTTPublishPacket: |
536 | 539 | let newPacket = MQTTPublishPacket( |
|
0 commit comments