diff --git a/Sources/FusionKit/Error/FKConnectionError.swift b/Sources/FusionKit/Error/FKConnectionError.swift index 33f29b9..36cf8dd 100644 --- a/Sources/FusionKit/Error/FKConnectionError.swift +++ b/Sources/FusionKit/Error/FKConnectionError.swift @@ -14,7 +14,6 @@ public enum FKConnectionError: Error { case missingHost case missingPort case connectionTimeout - case connectionUnsatisfied case parsingFailed case readBufferOverflow case writeBufferOverflow @@ -25,7 +24,6 @@ public enum FKConnectionError: Error { case .missingHost: return "missing host" case .missingPort: return "missing port" case .connectionTimeout: return "connection timeout" - case .connectionUnsatisfied: return "connection path is not satisfied" case .parsingFailed: return "message parsing failed" case .readBufferOverflow: return "read buffer overflow" case .writeBufferOverflow: return "write buffer overflow" diff --git a/Sources/FusionKit/Extensions/Extensions.swift b/Sources/FusionKit/Extensions/Extensions.swift index c191ea0..cd93739 100644 --- a/Sources/FusionKit/Extensions/Extensions.swift +++ b/Sources/FusionKit/Extensions/Extensions.swift @@ -19,7 +19,7 @@ internal extension Timer { /// - completion: completion /// - Returns: a source timer static func timeout(after: TimeInterval = 3.0, _ completion: @escaping () -> Void) -> DispatchSourceTimer { - let dispatchTimer = DispatchSource.makeTimerSource(flags: .strict, queue: DispatchQueue(label: UUID().uuidString)) + let dispatchTimer = DispatchSource.makeTimerSource(flags: .strict, queue: DispatchQueue(label: UUID().uuidString, qos: .userInteractive)) dispatchTimer.setEventHandler(handler: completion) dispatchTimer.schedule(deadline: .now() + after, repeating: .never) dispatchTimer.resume() diff --git a/Sources/FusionKit/Model/FKConnection.swift b/Sources/FusionKit/Model/FKConnection.swift index aaebcce..a10b11a 100644 --- a/Sources/FusionKit/Model/FKConnection.swift +++ b/Sources/FusionKit/Model/FKConnection.swift @@ -27,9 +27,8 @@ public final class FKConnection: FKConnectionProtocol { /// - port: the host port /// - parameters: network parameters /// - queue: dispatch queue - public required init(host: String, port: UInt16, parameters: NWParameters = .tcp, queue: DispatchQueue = .init(label: UUID().uuidString)) { - if host.isEmpty { fatalError(FKConnectionError.missingHost.description) } - if port == .zero { fatalError(FKConnectionError.missingPort.description) } + public required init(host: String, port: UInt16, parameters: NWParameters = .tcp, queue: DispatchQueue = .init(label: UUID().uuidString, qos: .userInteractive)) { + if host.isEmpty { fatalError(FKConnectionError.missingHost.description) }; if port == .zero { fatalError(FKConnectionError.missingPort.description) } self.connection = NWConnection(host: NWEndpoint.Host(host), port: NWEndpoint.Port(integerLiteral: port), using: parameters) self.queue = queue } @@ -115,9 +114,7 @@ private extension FKConnection { private func cleanup() -> Void { self.queue.async { [weak self] in guard let self else { return } - invalidate() - connection.cancel() - framer.reset() + invalidate(); connection.cancel(); framer.reset() } } diff --git a/Sources/FusionKit/Model/FKConnectionOpcodes.swift b/Sources/FusionKit/Model/FKConnectionOpcodes.swift index 22b65e4..caa4cd7 100644 --- a/Sources/FusionKit/Model/FKConnectionOpcodes.swift +++ b/Sources/FusionKit/Model/FKConnectionOpcodes.swift @@ -17,7 +17,7 @@ internal enum FKConnectionOpcodes: UInt8 { case ping = 0x3 } -/// Protocol byte numbers +/// Protocol byte constants @frozen internal enum FKConnectionConstants: Int { case opcode = 0x1 diff --git a/Sources/FusionKit/Protocols/FKConnectionProtocol.swift b/Sources/FusionKit/Protocols/FKConnectionProtocol.swift index cfcf496..8c55b3a 100644 --- a/Sources/FusionKit/Protocols/FKConnectionProtocol.swift +++ b/Sources/FusionKit/Protocols/FKConnectionProtocol.swift @@ -10,7 +10,7 @@ import Foundation import Network internal protocol FKConnectionProtocol { - /// Access to connection State's + /// The `FKConnectionState` update values var stateUpdateHandler: (FKConnectionState) -> Void { get set } /// The `FKConnection` is a custom Network protocol implementation of the Fusion Framing Protocol. diff --git a/Tests/FusionKitTests/FusionKitTests.swift b/Tests/FusionKitTests/FusionKitTests.swift index f719fa9..cde3b04 100644 --- a/Tests/FusionKitTests/FusionKitTests.swift +++ b/Tests/FusionKitTests/FusionKitTests.swift @@ -16,7 +16,7 @@ private enum TestCase { } class FusionKitTests: XCTestCase { - private var connection = FKConnection(host: "atonet.de", port: 7878) + private var connection = FKConnection(host: "weist.org", port: 7878) private var buffer = "50000" private let timeout = 10.0 private let uuid = UUID().uuidString @@ -59,7 +59,6 @@ class FusionKitTests: XCTestCase { XCTAssertEqual(FKConnectionError.missingHost.description, "missing host") XCTAssertEqual(FKConnectionError.missingPort.description, "missing port") XCTAssertEqual(FKConnectionError.connectionTimeout.description, "connection timeout") - XCTAssertEqual(FKConnectionError.connectionUnsatisfied.description, "connection path is not satisfied") XCTAssertEqual(FKConnectionError.parsingFailed.description, "message parsing failed") XCTAssertEqual(FKConnectionError.readBufferOverflow.description, "read buffer overflow") XCTAssertEqual(FKConnectionError.writeBufferOverflow.description, "write buffer overflow")