Loading Kinetic/Encoding.swift +22 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,16 @@ public struct KineticEncoding { public enum Error: ErrorType { // normal case when the connection is closed. (eof on the identifier) case Closed // An EoF happened while reading the remainder of the header. case InvalidStream // there was 9 bytes, but the identifier was not correct. Stream out of sync. case InvalidIdentifier } public struct Header { public let bytes: Bytes Loading @@ -35,8 +45,19 @@ public struct KineticEncoding { return Int(bytesToUInt32(self.bytes, offset: 5)) } public init(bytes: Bytes) { public init(bytes: Bytes) throws { switch bytes.count { case 9: break case 0: throw Error.Closed default: throw Error.InvalidStream } self.bytes = bytes guard isValid else { throw Error.InvalidIdentifier } } public init(protoLength: Int, valueLength: Int) { Loading Kinetic/Session.swift +1 −2 Original line number Diff line number Diff line Loading @@ -92,10 +92,9 @@ public class KineticSession { // Reader dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)) { debugPrint("Background reader for \(self.connectionId!) is active.") while self.connected { do { debugPrint("waiting...") debugPrint("waiting for \(self.connectionId!) ...") let raw = try self.channel.receive() debugPrint("Background loops seems to work... Ack:\(raw.command.header.ackSequence)") if let x = self.pending[raw.command.header.ackSequence] { Loading KineticTests/KineticTests.swift +17 −3 Original line number Diff line number Diff line Loading @@ -23,13 +23,27 @@ class KineticTests: XCTestCase { } override func tearDown() { // Put teardown code here. This method is called after the invocation of each test method in the class. c!.close() XCTAssertFalse(c!.connected) super.tearDown() } func testExample() { // This is an example of a functional test case. // Use XCTAssert and related functions to verify your tests produce the correct results. do { //: Write a key/value pair try c!.put("hello", value: "world") //: Read the value back let x = try c!.get("hello") //: The Strings on the methods are just for convenience //: the actual values are byte arrays `[UInt8]` print("Received: \(x.value!.toUtf8String())") }catch let x { XCTFail(String(x)) } } func testPerformanceExample() { Loading Podfile.lock +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ CHECKOUT OPTIONS: :commit: ad4db3095a9ccc034c1eb65934a89c670012e6a0 :git: https://github.com/krzyzanowskim/CryptoSwift Socket: :commit: ece06de15752c013e14d15d9e5c1aeefc70b1ea7 :commit: aa3a929fb2bdb8517e7a446c1376d1dedbdaceb3 :git: https://github.com/jphughes/socket-swift SPEC CHECKSUMS: Loading Pods/Manifest.lock +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ CHECKOUT OPTIONS: :commit: ad4db3095a9ccc034c1eb65934a89c670012e6a0 :git: https://github.com/krzyzanowskim/CryptoSwift Socket: :commit: ece06de15752c013e14d15d9e5c1aeefc70b1ea7 :commit: aa3a929fb2bdb8517e7a446c1376d1dedbdaceb3 :git: https://github.com/jphughes/socket-swift SPEC CHECKSUMS: Loading Loading
Kinetic/Encoding.swift +22 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,16 @@ public struct KineticEncoding { public enum Error: ErrorType { // normal case when the connection is closed. (eof on the identifier) case Closed // An EoF happened while reading the remainder of the header. case InvalidStream // there was 9 bytes, but the identifier was not correct. Stream out of sync. case InvalidIdentifier } public struct Header { public let bytes: Bytes Loading @@ -35,8 +45,19 @@ public struct KineticEncoding { return Int(bytesToUInt32(self.bytes, offset: 5)) } public init(bytes: Bytes) { public init(bytes: Bytes) throws { switch bytes.count { case 9: break case 0: throw Error.Closed default: throw Error.InvalidStream } self.bytes = bytes guard isValid else { throw Error.InvalidIdentifier } } public init(protoLength: Int, valueLength: Int) { Loading
Kinetic/Session.swift +1 −2 Original line number Diff line number Diff line Loading @@ -92,10 +92,9 @@ public class KineticSession { // Reader dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)) { debugPrint("Background reader for \(self.connectionId!) is active.") while self.connected { do { debugPrint("waiting...") debugPrint("waiting for \(self.connectionId!) ...") let raw = try self.channel.receive() debugPrint("Background loops seems to work... Ack:\(raw.command.header.ackSequence)") if let x = self.pending[raw.command.header.ackSequence] { Loading
KineticTests/KineticTests.swift +17 −3 Original line number Diff line number Diff line Loading @@ -23,13 +23,27 @@ class KineticTests: XCTestCase { } override func tearDown() { // Put teardown code here. This method is called after the invocation of each test method in the class. c!.close() XCTAssertFalse(c!.connected) super.tearDown() } func testExample() { // This is an example of a functional test case. // Use XCTAssert and related functions to verify your tests produce the correct results. do { //: Write a key/value pair try c!.put("hello", value: "world") //: Read the value back let x = try c!.get("hello") //: The Strings on the methods are just for convenience //: the actual values are byte arrays `[UInt8]` print("Received: \(x.value!.toUtf8String())") }catch let x { XCTFail(String(x)) } } func testPerformanceExample() { Loading
Podfile.lock +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ CHECKOUT OPTIONS: :commit: ad4db3095a9ccc034c1eb65934a89c670012e6a0 :git: https://github.com/krzyzanowskim/CryptoSwift Socket: :commit: ece06de15752c013e14d15d9e5c1aeefc70b1ea7 :commit: aa3a929fb2bdb8517e7a446c1376d1dedbdaceb3 :git: https://github.com/jphughes/socket-swift SPEC CHECKSUMS: Loading
Pods/Manifest.lock +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ CHECKOUT OPTIONS: :commit: ad4db3095a9ccc034c1eb65934a89c670012e6a0 :git: https://github.com/krzyzanowskim/CryptoSwift Socket: :commit: ece06de15752c013e14d15d9e5c1aeefc70b1ea7 :commit: aa3a929fb2bdb8517e7a446c1376d1dedbdaceb3 :git: https://github.com/jphughes/socket-swift SPEC CHECKSUMS: Loading