From ee63c4e3861580fdbe137373343b3c649fda5b0f Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 2 Aug 2016 20:14:04 -0400 Subject: [PATCH 01/10] refactor out checking for base64 --- Source/SocketEngine.swift | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Source/SocketEngine.swift b/Source/SocketEngine.swift index fb41c09..e80b703 100644 --- a/Source/SocketEngine.swift +++ b/Source/SocketEngine.swift @@ -153,18 +153,12 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo } } - private func checkIfMessageIsBase64Binary(message: String) -> Bool { - if message.hasPrefix("b4") { - // binary in base64 string - let noPrefix = message[message.startIndex.advancedBy(2).. Date: Tue, 2 Aug 2016 20:35:41 -0400 Subject: [PATCH 02/10] move extensions --- Source/SocketExtensions.swift | 69 +++++++++++++++++++++++++++++++ Source/SocketIOClientOption.swift | 69 ------------------------------- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/Source/SocketExtensions.swift b/Source/SocketExtensions.swift index 74f032b..0cf05b3 100644 --- a/Source/SocketExtensions.swift +++ b/Source/SocketExtensions.swift @@ -41,6 +41,75 @@ extension NSCharacterSet { } } +extension NSDictionary { + private static func keyValueToSocketIOClientOption(key: String, value: AnyObject) -> SocketIOClientOption? { + switch (key, value) { + case let ("connectParams", params as [String: AnyObject]): + return .ConnectParams(params) + case let ("cookies", cookies as [NSHTTPCookie]): + return .Cookies(cookies) + case let ("doubleEncodeUTF8", encode as Bool): + return .DoubleEncodeUTF8(encode) + case let ("extraHeaders", headers as [String: String]): + return .ExtraHeaders(headers) + case let ("forceNew", force as Bool): + return .ForceNew(force) + case let ("forcePolling", force as Bool): + return .ForcePolling(force) + case let ("forceWebsockets", force as Bool): + return .ForceWebsockets(force) + case let ("handleQueue", queue as dispatch_queue_t): + return .HandleQueue(queue) + case let ("log", log as Bool): + return .Log(log) + case let ("logger", logger as SocketLogger): + return .Logger(logger) + case let ("nsp", nsp as String): + return .Nsp(nsp) + case let ("path", path as String): + return .Path(path) + case let ("reconnects", reconnects as Bool): + return .Reconnects(reconnects) + case let ("reconnectAttempts", attempts as Int): + return .ReconnectAttempts(attempts) + case let ("reconnectWait", wait as Int): + return .ReconnectWait(wait) + case let ("secure", secure as Bool): + return .Secure(secure) + case let ("security", security as SSLSecurity): + return .Security(security) + case let ("selfSigned", selfSigned as Bool): + return .SelfSigned(selfSigned) + case let ("sessionDelegate", delegate as NSURLSessionDelegate): + return .SessionDelegate(delegate) + case let ("voipEnabled", enable as Bool): + return .VoipEnabled(enable) + default: + return nil + } + } + + func toSocketOptionsSet() -> Set { + var options = Set() + + for (rawKey, value) in self { + if let key = rawKey as? String, opt = NSDictionary.keyValueToSocketIOClientOption(key, value: value) { + options.insertIgnore(opt) + } + } + + return options + } +} + +extension Set where Element : ClientOption { + mutating func insertIgnore(element: Element) { + if !contains(element) { + insert(element) + } + } +} + extension String { func toArray() throws -> [AnyObject] { guard let stringData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) else { return [] } diff --git a/Source/SocketIOClientOption.swift b/Source/SocketIOClientOption.swift index d7a0d8d..bf616ff 100644 --- a/Source/SocketIOClientOption.swift +++ b/Source/SocketIOClientOption.swift @@ -156,72 +156,3 @@ public enum SocketIOClientOption : ClientOption { public func ==(lhs: SocketIOClientOption, rhs: SocketIOClientOption) -> Bool { return lhs.description == rhs.description } - -extension Set where Element : ClientOption { - mutating func insertIgnore(element: Element) { - if !contains(element) { - insert(element) - } - } -} - -extension NSDictionary { - private static func keyValueToSocketIOClientOption(key: String, value: AnyObject) -> SocketIOClientOption? { - switch (key, value) { - case let ("connectParams", params as [String: AnyObject]): - return .ConnectParams(params) - case let ("cookies", cookies as [NSHTTPCookie]): - return .Cookies(cookies) - case let ("doubleEncodeUTF8", encode as Bool): - return .DoubleEncodeUTF8(encode) - case let ("extraHeaders", headers as [String: String]): - return .ExtraHeaders(headers) - case let ("forceNew", force as Bool): - return .ForceNew(force) - case let ("forcePolling", force as Bool): - return .ForcePolling(force) - case let ("forceWebsockets", force as Bool): - return .ForceWebsockets(force) - case let ("handleQueue", queue as dispatch_queue_t): - return .HandleQueue(queue) - case let ("log", log as Bool): - return .Log(log) - case let ("logger", logger as SocketLogger): - return .Logger(logger) - case let ("nsp", nsp as String): - return .Nsp(nsp) - case let ("path", path as String): - return .Path(path) - case let ("reconnects", reconnects as Bool): - return .Reconnects(reconnects) - case let ("reconnectAttempts", attempts as Int): - return .ReconnectAttempts(attempts) - case let ("reconnectWait", wait as Int): - return .ReconnectWait(wait) - case let ("secure", secure as Bool): - return .Secure(secure) - case let ("security", security as SSLSecurity): - return .Security(security) - case let ("selfSigned", selfSigned as Bool): - return .SelfSigned(selfSigned) - case let ("sessionDelegate", delegate as NSURLSessionDelegate): - return .SessionDelegate(delegate) - case let ("voipEnabled", enable as Bool): - return .VoipEnabled(enable) - default: - return nil - } - } - - func toSocketOptionsSet() -> Set { - var options = Set() - - for (rawKey, value) in self { - if let key = rawKey as? String, opt = NSDictionary.keyValueToSocketIOClientOption(key, value: value) { - options.insertIgnore(opt) - } - } - - return options - } -} From b6cb0b2c7bc8c795c9b53262b5450aa799f8146b Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 8 Aug 2016 18:24:42 -0400 Subject: [PATCH 03/10] bump websocket version --- Source/SSLSecurity.swift | 4 +- Source/SocketEngine.swift | 2 +- Source/WebSocket.swift | 166 ++++++++++++++++++++++---------------- 3 files changed, 100 insertions(+), 72 deletions(-) diff --git a/Source/SSLSecurity.swift b/Source/SSLSecurity.swift index 4ce1f7a..c43ba83 100644 --- a/Source/SSLSecurity.swift +++ b/Source/SSLSecurity.swift @@ -88,10 +88,10 @@ public class SSLSecurity : NSObject { - returns: a representation security object to be used with */ public init(certs: [SSLCert], usePublicKeys: Bool) { - super.init() - self.usePublicKeys = usePublicKeys + super.init() + if self.usePublicKeys { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0)) { let pubKeys = certs.reduce([SecKeyRef]()) { (pubKeys: [SecKeyRef], cert: SSLCert) -> [SecKeyRef] in diff --git a/Source/SocketEngine.swift b/Source/SocketEngine.swift index e80b703..0a848a2 100644 --- a/Source/SocketEngine.swift +++ b/Source/SocketEngine.swift @@ -259,7 +259,7 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo } } - ws?.queue = handleQueue + ws?.callbackQueue = handleQueue ws?.voipEnabled = voipEnabled ws?.delegate = self ws?.selfSignedSSL = selfSigned diff --git a/Source/WebSocket.swift b/Source/WebSocket.swift index 1204a78..ce3c023 100644 --- a/Source/WebSocket.swift +++ b/Source/WebSocket.swift @@ -38,44 +38,46 @@ public protocol WebSocketPongDelegate: class { func websocketDidReceivePong(socket: WebSocket) } -public class WebSocket : NSObject, NSStreamDelegate { +public class WebSocket: NSObject, NSStreamDelegate { - enum OpCode : UInt8 { + enum OpCode: UInt8 { case ContinueFrame = 0x0 case TextFrame = 0x1 case BinaryFrame = 0x2 - //3-7 are reserved. + // 3-7 are reserved. case ConnectionClose = 0x8 case Ping = 0x9 case Pong = 0xA - //B-F reserved. + // B-F reserved. } - public enum CloseCode : UInt16 { + public enum CloseCode: UInt16 { case Normal = 1000 case GoingAway = 1001 case ProtocolError = 1002 case ProtocolUnhandledType = 1003 // 1004 reserved. case NoStatusReceived = 1005 - //1006 reserved. + // 1006 reserved. case Encoding = 1007 case PolicyViolated = 1008 case MessageTooBig = 1009 } - public static let ErrorDomain = "WebSocket" + public static let ErrorDomain = "WebSocket" - enum InternalErrorCode : UInt16 { + enum InternalErrorCode: UInt16 { // 0-999 WebSocket status codes not used case OutputStreamWriteError = 1 } - //Where the callback is executed. It defaults to the main UI thread queue. - public var queue = dispatch_get_main_queue() + /// Where the callback is executed. It defaults to the main UI thread queue. + public var callbackQueue = dispatch_get_main_queue() var optionalProtocols : [String]? - //Constant Values. + + // MARK: - Constants + let headerWSUpgradeName = "Upgrade" let headerWSUpgradeValue = "websocket" let headerWSHostName = "Host" @@ -94,6 +96,8 @@ public class WebSocket : NSObject, NSStreamDelegate { let MaskMask: UInt8 = 0x80 let PayloadLenMask: UInt8 = 0x7F let MaxFrameSize: Int = 32 + let httpSwitchProtocolCode = 101 + let supportedSSLSchemes = ["wss", "https"] class WSResponse { var isFin = false @@ -103,13 +107,24 @@ public class WebSocket : NSObject, NSStreamDelegate { var buffer: NSMutableData? } + // MARK: - Delegates + + /// Responds to callback about new messages coming in over the WebSocket + /// and also connection/disconnect messages. public weak var delegate: WebSocketDelegate? + + /// Recives a callback for each pong message recived. public weak var pongDelegate: WebSocketPongDelegate? + + + // MARK: - Block based API. + public var onConnect: ((Void) -> Void)? public var onDisconnect: ((NSError?) -> Void)? public var onText: ((String) -> Void)? public var onData: ((NSData) -> Void)? public var onPong: ((Void) -> Void)? + public var headers = [String: String]() public var voipEnabled = false public var selfSignedSSL = false @@ -120,12 +135,15 @@ public class WebSocket : NSObject, NSStreamDelegate { public var isConnected :Bool { return connected } - public var currentURL: NSURL {return url} + public var currentURL: NSURL { return url } + + // MARK: - Private + private var url: NSURL private var inputStream: NSInputStream? private var outputStream: NSOutputStream? private var connected = false - private var isCreated = false + private var isConnecting = false private var writeQueue = NSOperationQueue() private var readStack = [WSResponse]() private var inputQueue = [NSData]() @@ -141,10 +159,11 @@ public class WebSocket : NSObject, NSStreamDelegate { mutex.unlock() return canWork } - //the shared processing queue used for all websocket + + /// The shared processing queue used for all WebSocket. private static let sharedWorkQueue = dispatch_queue_create("com.vluxe.starscream.websocket", DISPATCH_QUEUE_SERIAL) - //used for setting protocols. + /// Used for setting protocols. public init(url: NSURL, protocols: [String]? = nil) { self.url = url self.origin = url.absoluteString @@ -152,13 +171,13 @@ public class WebSocket : NSObject, NSStreamDelegate { optionalProtocols = protocols } - ///Connect to the websocket server on a background thread + /// Connect to the WebSocket server on a background thread. public func connect() { - guard !isCreated else { return } + guard !isConnecting else { return } didDisconnect = false - isCreated = true + isConnecting = true createHTTPRequest() - isCreated = false + isConnecting = false } /** @@ -173,7 +192,7 @@ public class WebSocket : NSObject, NSStreamDelegate { public func disconnect(forceTimeout forceTimeout: NSTimeInterval? = nil) { switch forceTimeout { case .Some(let seconds) where seconds > 0: - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(seconds * Double(NSEC_PER_SEC))), queue) { [weak self] in + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(seconds * Double(NSEC_PER_SEC))), callbackQueue) { [weak self] in self?.disconnectStream(nil) } fallthrough @@ -181,7 +200,7 @@ public class WebSocket : NSObject, NSStreamDelegate { writeError(CloseCode.Normal.rawValue) default: - self.disconnectStream(nil) + disconnectStream(nil) break } } @@ -212,14 +231,14 @@ public class WebSocket : NSObject, NSStreamDelegate { dequeueWrite(data, code: .BinaryFrame, writeCompletion: completion) } - //write a ping to the websocket. This sends it as a control frame. - //yodel a sound to the planet. This sends it as an astroid. http://youtu.be/Eu5ZJELRiJ8?t=42s + // Write a ping to the websocket. This sends it as a control frame. + // Yodel a sound to the planet. This sends it as an astroid. http://youtu.be/Eu5ZJELRiJ8?t=42s public func writePing(data: NSData, completion: (() -> ())? = nil) { guard isConnected else { return } dequeueWrite(data, code: .Ping, writeCompletion: completion) } - //private method that starts the connection + /// Private method that starts the connection. private func createHTTPRequest() { let urlRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault, "GET", @@ -227,7 +246,7 @@ public class WebSocket : NSObject, NSStreamDelegate { var port = url.port if port == nil { - if ["wss", "https"].contains(url.scheme) { + if supportedSSLSchemes.contains(url.scheme) { port = 443 } else { port = 80 @@ -253,12 +272,12 @@ public class WebSocket : NSObject, NSStreamDelegate { } } - //Add a header to the CFHTTPMessage by using the NSString bridges to CFString + /// Add a header to the CFHTTPMessage by using the NSString bridges to CFString. private func addHeader(urlRequest: CFHTTPMessage, key: NSString, val: NSString) { CFHTTPMessageSetHeaderFieldValue(urlRequest, key, val) } - //generate a websocket key as needed in rfc + /// Generate a WebSocket key as needed in RFC. private func generateWebSocketKey() -> String { var key = "" let seed = 16 @@ -271,7 +290,7 @@ public class WebSocket : NSObject, NSStreamDelegate { return baseKey! } - //Start the stream connection and write the data to the output stream + /// Start the stream connection and write the data to the output stream. private func initStreamsWithData(data: NSData, _ port: Int) { //higher level API we will cut over to at some point //NSStream.getStreamsToHostWithName(url.host, port: url.port.integerValue, inputStream: &inputStream, outputStream: &outputStream) @@ -285,7 +304,7 @@ public class WebSocket : NSObject, NSStreamDelegate { guard let inStream = inputStream, let outStream = outputStream else { return } inStream.delegate = self outStream.delegate = self - if ["wss", "https"].contains(url.scheme) { + if supportedSSLSchemes.contains(url.scheme) { inStream.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey) outStream.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey) } else { @@ -296,7 +315,7 @@ public class WebSocket : NSObject, NSStreamDelegate { outStream.setProperty(NSStreamNetworkServiceTypeVoIP, forKey: NSStreamNetworkServiceType) } if selfSignedSSL { - let settings: [NSObject: NSObject] = [kCFStreamSSLValidatesCertificateChain: NSNumber(bool:false), kCFStreamSSLPeerName: kCFNull] + let settings: [NSObject: NSObject] = [kCFStreamSSLValidatesCertificateChain: NSNumber(bool: false), kCFStreamSSLPeerName: kCFNull] inStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as String) outStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as String) } @@ -327,23 +346,24 @@ public class WebSocket : NSObject, NSStreamDelegate { self.mutex.unlock() let bytes = UnsafePointer(data.bytes) - var out = timeout * 1000000 //wait 5 seconds before giving up + var out = timeout * 1000000 // wait 5 seconds before giving up writeQueue.addOperationWithBlock { [weak self] in while !outStream.hasSpaceAvailable { - usleep(100) //wait until the socket is ready + usleep(100) // wait until the socket is ready out -= 100 if out < 0 { self?.cleanupStream() self?.doDisconnect(self?.errorWithDetail("write wait timed out", code: 2)) return } else if outStream.streamError != nil { - return //disconnectStream will be called. + return // disconnectStream will be called. } } outStream.write(bytes, maxLength: data.length) } } - //delegate for the stream methods. Processes incoming bytes + + // Delegate for the stream methods. Processes incoming bytes. public func stream(aStream: NSStream, handleEvent eventCode: NSStreamEvent) { if let sec = security where !certValidated && [.HasBytesAvailable, .HasSpaceAvailable].contains(eventCode) { @@ -369,7 +389,8 @@ public class WebSocket : NSObject, NSStreamDelegate { disconnectStream(nil) } } - //disconnect the stream object + + /// Disconnect the stream object and notifies the delegate. private func disconnectStream(error: NSError?) { if error == nil { writeQueue.waitUntilAllOperationsAreFinished() @@ -395,7 +416,7 @@ public class WebSocket : NSObject, NSStreamDelegate { inputStream = nil } - ///handles the incoming bytes and sending them to the proper processing method + /// Handles the incoming bytes and sending them to the proper processing method. private func processInputStream() { let buf = NSMutableData(capacity: BUFFER_MAX) let buffer = UnsafeMutablePointer(buf!.bytes) @@ -411,7 +432,8 @@ public class WebSocket : NSObject, NSStreamDelegate { dequeueInput() } } - ///dequeue the incoming input so it is processed in order + + /// Dequeue the incoming input so it is processed in order. private func dequeueInput() { while !inputQueue.isEmpty { let data = inputQueue[0] @@ -429,18 +451,18 @@ public class WebSocket : NSObject, NSStreamDelegate { } else { processRawMessagesInBuffer(buffer, bufferLen: length) } - inputQueue = inputQueue.filter{$0 != data} + inputQueue = inputQueue.filter{ $0 != data } } } - //handle checking the inital connection status + // Handle checking the initial connection status. private func processTCPHandshake(buffer: UnsafePointer, bufferLen: Int) { let code = processHTTP(buffer, bufferLen: bufferLen) switch code { case 0: connected = true guard canDispatch else {return} - dispatch_async(queue) { [weak self] in + dispatch_async(callbackQueue) { [weak self] in guard let s = self else { return } s.onConnect?() s.delegate?.websocketDidConnect(s) @@ -448,12 +470,13 @@ public class WebSocket : NSObject, NSStreamDelegate { } case -1: fragBuffer = NSData(bytes: buffer, length: bufferLen) - break //do nothing, we are going to collect more data + break // do nothing, we are going to collect more data default: doDisconnect(errorWithDetail("Invalid HTTP upgrade", code: UInt16(code))) } } - ///Finds the HTTP Packet in the TCP stream, by looking for the CRLF. + + /// Finds the HTTP Packet in the TCP stream, by looking for the CRLF. private func processHTTP(buffer: UnsafePointer, bufferLen: Int) -> Int { let CRLFBytes = [UInt8(ascii: "\r"), UInt8(ascii: "\n"), UInt8(ascii: "\r"), UInt8(ascii: "\n")] var k = 0 @@ -481,15 +504,15 @@ public class WebSocket : NSObject, NSStreamDelegate { } return 0 //success } - return -1 //was unable to find the full TCP header + return -1 // Was unable to find the full TCP header. } - ///validates the HTTP is a 101 as per the RFC spec + /// Validates the HTTP is a 101 as per the RFC spec. private func validateResponse(buffer: UnsafePointer, bufferLen: Int) -> Int { let response = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, false).takeRetainedValue() CFHTTPMessageAppendBytes(response, buffer, bufferLen) let code = CFHTTPMessageGetResponseStatusCode(response) - if code != 101 { + if code != httpSwitchProtocolCode { return code } if let cfHeaders = CFHTTPMessageCopyAllHeaderFields(response) { @@ -503,12 +526,12 @@ public class WebSocket : NSObject, NSStreamDelegate { return -1 } - ///read a 16 bit big endian value from a buffer + ///read a 16-bit big endian value from a buffer private static func readUint16(buffer: UnsafePointer, offset: Int) -> UInt16 { return (UInt16(buffer[offset + 0]) << 8) | UInt16(buffer[offset + 1]) } - ///read a 64 bit big endian value from a buffer + ///read a 64-bit big endian value from a buffer private static func readUint64(buffer: UnsafePointer, offset: Int) -> UInt64 { var value = UInt64(0) for i in 0...7 { @@ -517,13 +540,13 @@ public class WebSocket : NSObject, NSStreamDelegate { return value } - ///write a 16 bit big endian value to a buffer + /// Write a 16-bit big endian value to a buffer. private static func writeUint16(buffer: UnsafeMutablePointer, offset: Int, value: UInt16) { buffer[offset + 0] = UInt8(value >> 8) buffer[offset + 1] = UInt8(value & 0xff) } - ///write a 64 bit big endian value to a buffer + /// Write a 64-bit big endian value to a buffer. private static func writeUint64(buffer: UnsafeMutablePointer, offset: Int, value: UInt64) { for i in 0...7 { buffer[offset + i] = UInt8((value >> (8*UInt64(7 - i))) & 0xff) @@ -588,17 +611,19 @@ public class WebSocket : NSObject, NSStreamDelegate { } offset += 2 } + var closeReason = "connection closed by server" if payloadLen > 2 { - let len = Int(payloadLen-2) + let len = Int(payloadLen - 2) if len > 0 { let bytes = baseAddress + offset - let str: NSString? = NSString(data: NSData(bytes: bytes, length: len), encoding: NSUTF8StringEncoding) - if str == nil { + if let customCloseReason = String(data: NSData(bytes: bytes, length: len), encoding: NSUTF8StringEncoding) { + closeReason = customCloseReason + } else { code = CloseCode.ProtocolError.rawValue } } } - doDisconnect(errorWithDetail("connection closed by server", code: code)) + doDisconnect(errorWithDetail(closeReason, code: code)) writeError(code) return emptyBuffer } @@ -631,7 +656,7 @@ public class WebSocket : NSObject, NSStreamDelegate { } if receivedOpcode == .Pong { if canDispatch { - dispatch_async(queue) { [weak self] in + dispatch_async(callbackQueue) { [weak self] in guard let s = self else { return } s.onPong?() s.pongDelegate?.websocketDidReceivePong(s) @@ -641,7 +666,7 @@ public class WebSocket : NSObject, NSStreamDelegate { } var response = readStack.last if isControlFrame { - response = nil //don't append pings + response = nil // Don't append pings. } if isFin == 0 && receivedOpcode == .ContinueFrame && response == nil { let errCode = CloseCode.ProtocolError.rawValue @@ -685,7 +710,7 @@ public class WebSocket : NSObject, NSStreamDelegate { processResponse(response) } - let step = Int(offset+numericCast(len)) + let step = Int(offset + numericCast(len)) return buffer.fromOffset(step) } } @@ -701,11 +726,11 @@ public class WebSocket : NSObject, NSStreamDelegate { } } - ///process the finished response of a buffer + /// Process the finished response of a buffer. private func processResponse(response: WSResponse) -> Bool { if response.isFin && response.bytesLeft <= 0 { if response.code == .Ping { - let data = response.buffer! //local copy so it is perverse for writing + let data = response.buffer! // local copy so it's not perverse for writing dequeueWrite(data, code: OpCode.Pong) } else if response.code == .TextFrame { let str: NSString? = NSString(data: response.buffer!, encoding: NSUTF8StringEncoding) @@ -714,7 +739,7 @@ public class WebSocket : NSObject, NSStreamDelegate { return false } if canDispatch { - dispatch_async(queue) { [weak self] in + dispatch_async(callbackQueue) { [weak self] in guard let s = self else { return } s.onText?(str! as String) s.delegate?.websocketDidReceiveMessage(s, text: str! as String) @@ -722,8 +747,8 @@ public class WebSocket : NSObject, NSStreamDelegate { } } else if response.code == .BinaryFrame { if canDispatch { - let data = response.buffer! //local copy so it is perverse for writing - dispatch_async(queue) { [weak self] in + let data = response.buffer! //local copy so it's not perverse for writing + dispatch_async(callbackQueue) { [weak self] in guard let s = self else { return } s.onData?(data) s.delegate?.websocketDidReceiveData(s, data: data) @@ -736,21 +761,22 @@ public class WebSocket : NSObject, NSStreamDelegate { return false } - ///Create an error + /// Create an error. private func errorWithDetail(detail: String, code: UInt16) -> NSError { var details = [String: String]() details[NSLocalizedDescriptionKey] = detail return NSError(domain: WebSocket.ErrorDomain, code: Int(code), userInfo: details) } - ///write a an error to the socket + /// Write a an error to the socket. private func writeError(code: UInt16) { let buf = NSMutableData(capacity: sizeof(UInt16)) let buffer = UnsafeMutablePointer(buf!.bytes) WebSocket.writeUint16(buffer, offset: 0, value: code) dequeueWrite(NSData(bytes: buffer, length: sizeof(UInt16)), code: .ConnectionClose) } - ///used to write things to the stream + + /// Used to write things to the stream. private func dequeueWrite(data: NSData, code: OpCode, writeCompletion: (() -> ())? = nil) { writeQueue.addOperationWithBlock { [weak self] in //stream isn't ready, let's wait @@ -800,8 +826,8 @@ public class WebSocket : NSObject, NSStreamDelegate { total += len } if total >= offset { - if let queue = self?.queue, callback = writeCompletion { - dispatch_async(queue) { + if let callbackQueue = self?.callbackQueue, callback = writeCompletion { + dispatch_async(callbackQueue) { callback() } } @@ -813,21 +839,23 @@ public class WebSocket : NSObject, NSStreamDelegate { } } - ///used to preform the disconnect delegate + /// Used to preform the disconnect delegate. private func doDisconnect(error: NSError?) { guard !didDisconnect else { return } didDisconnect = true connected = false guard canDispatch else {return} - dispatch_async(queue) { [weak self] in + dispatch_async(callbackQueue) { [weak self] in guard let s = self else { return } s.onDisconnect?(error) s.delegate?.websocketDidDisconnect(s, error: error) - let userInfo = error.map({ [WebsocketDisconnectionErrorKeyName: $0] }) + let userInfo = error.map{ [WebsocketDisconnectionErrorKeyName: $0] } s.notificationCenter.postNotificationName(WebsocketDidDisconnectNotification, object: self, userInfo: userInfo) } } + // MARK: - Deinit + deinit { mutex.lock() readyToWrite = false From 14b4df3836468c9382bf97b2c66b993cdc289990 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 11 Aug 2016 21:11:28 -0400 Subject: [PATCH 04/10] refactor some reconnect code --- Source/SocketIOClient.swift | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift index ca7fe19..b1a8658 100644 --- a/Source/SocketIOClient.swift +++ b/Source/SocketIOClient.swift @@ -413,18 +413,16 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable } private func tryReconnectWithReason(reason: String) { - if reconnecting { - DefaultSocketLogger.Logger.log("Starting reconnect", type: logType) - handleEvent("reconnect", data: [reason], isInternalMessage: true) - - _tryReconnect() - } + guard reconnecting else { return } + + DefaultSocketLogger.Logger.log("Starting reconnect", type: logType) + handleEvent("reconnect", data: [reason], isInternalMessage: true) + + _tryReconnect() } private func _tryReconnect() { - if !reconnecting { - return - } + guard reconnecting else { return } if reconnectAttempts != -1 && currentReconnectAttempt + 1 > reconnectAttempts || !reconnects { return didDisconnect("Reconnect Failed") From 437c983533b4fca405952113abe59f0df06baebc Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 11 Aug 2016 21:26:01 -0400 Subject: [PATCH 05/10] Rename variable --- Source/SocketIOClient.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift index b1a8658..a9d0e47 100644 --- a/Source/SocketIOClient.swift +++ b/Source/SocketIOClient.swift @@ -435,9 +435,9 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable currentReconnectAttempt += 1 connect() - let dispatchAfter = dispatch_time(DISPATCH_TIME_NOW, Int64(UInt64(reconnectWait) * NSEC_PER_SEC)) + let time = dispatch_time(DISPATCH_TIME_NOW, Int64(UInt64(reconnectWait) * NSEC_PER_SEC)) - dispatch_after(dispatchAfter, dispatch_get_main_queue(), _tryReconnect) + dispatch_after(time, dispatch_get_main_queue(), _tryReconnect) } } @@ -456,6 +456,6 @@ extension SocketIOClient { } func emitTest(event: String, _ data: AnyObject...) { - self._emit([event] + data) + _emit([event] + data) } } From e2bf84f576d809ef8d5ffa7d6630ef52d7866035 Mon Sep 17 00:00:00 2001 From: Erik Date: Sat, 13 Aug 2016 14:43:42 -0400 Subject: [PATCH 06/10] Add SocketIOClientConfiguration --- README.md | 6 +- .../project.pbxproj | 12 ++ .../SocketIOClientConfigurationTest.swift | 46 ++++++++ SocketIO-MacTests/SocketObjectiveCTest.m | 2 +- Source/SocketEngine.swift | 4 +- Source/SocketExtensions.swift | 14 +-- Source/SocketIOClient.swift | 18 +-- Source/SocketIOClientConfiguration.swift | 107 ++++++++++++++++++ Source/SocketIOClientOption.swift | 6 +- 9 files changed, 184 insertions(+), 31 deletions(-) create mode 100644 SocketIO-MacTests/SocketIOClientConfigurationTest.swift create mode 100644 Source/SocketIOClientConfiguration.swift diff --git a/README.md b/README.md index 7549222..f08ab7a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Socket.IO-client for iOS/OS X. ##Example ```swift -let socket = SocketIOClient(socketURL: NSURL(string: "http://localhost:8080")!, options: [.Log(true), .ForcePolling(true)]) +let socket = SocketIOClient(socketURL: NSURL(string: "http://localhost:8080")!, config: [.Log(true), .ForcePolling(true)]) socket.on("connect") {data, ack in print("socket connected") @@ -27,7 +27,7 @@ socket.connect() ##Objective-C Example ```objective-c NSURL* url = [[NSURL alloc] initWithString:@"http://localhost:8080"]; -SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url options:@{@"log": @YES, @"forcePolling": @YES}]; +SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{@"log": @YES, @"forcePolling": @YES}]; [socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) { NSLog(@"socket connected"); @@ -139,7 +139,7 @@ Run `seed install`. ##API Constructors ----------- -`init(var socketURL: NSURL, options: Set = [])` - Creates a new SocketIOClient. options is a Set of SocketIOClientOption. If your socket.io server is secure, you need to specify `https` in your socketURL. +`init(var socketURL: NSURL, config: SocketIOClientConfiguration = [])` - Creates a new SocketIOClient. options is a Set of SocketIOClientOption. If your socket.io server is secure, you need to specify `https` in your socketURL. `convenience init(socketURL: NSURL, options: NSDictionary?)` - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys. diff --git a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj index d005db9..98a0f57 100644 --- a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj +++ b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj @@ -115,6 +115,10 @@ 7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; }; 7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; }; 7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; }; + 747BC5991D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747BC5981D5F943500CA5FA4 /* SocketIOClientConfiguration.swift */; }; + 747BC59A1D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747BC5981D5F943500CA5FA4 /* SocketIOClientConfiguration.swift */; }; + 747BC59B1D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747BC5981D5F943500CA5FA4 /* SocketIOClientConfiguration.swift */; }; + 747BC59F1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747BC59E1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift */; }; 749642B51D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */; }; 749642B61D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */; }; 749642B71D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */; }; @@ -192,6 +196,8 @@ 74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketParserTest.swift; sourceTree = ""; }; 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespacePacketTest.swift; sourceTree = ""; }; 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketSideEffectTest.swift; sourceTree = ""; }; + 747BC5981D5F943500CA5FA4 /* SocketIOClientConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientConfiguration.swift; path = Source/SocketIOClientConfiguration.swift; sourceTree = ""; }; + 747BC59E1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketIOClientConfigurationTest.swift; sourceTree = ""; }; 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Source/SSLSecurity.swift; sourceTree = ""; }; 749642B41D3FCE5500DD32D1 /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = Source/WebSocket.swift; sourceTree = ""; }; 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientSpec.swift; path = Source/SocketIOClientSpec.swift; sourceTree = ""; }; @@ -314,6 +320,7 @@ 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */, 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */, 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */, + 747BC59E1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift */, 742D150B1CA5794B00BD987D /* SocketObjectiveCTest.m */, 74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */, 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */, @@ -346,6 +353,7 @@ 74171E571C10CD240062D398 /* SocketEventHandler.swift */, CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */, 74171E591C10CD240062D398 /* SocketIOClient.swift */, + 747BC5981D5F943500CA5FA4 /* SocketIOClientConfiguration.swift */, 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */, 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */, 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */, @@ -622,6 +630,7 @@ 74171EB71C10CD240062D398 /* SocketParsable.swift in Sources */, 74171E811C10CD240062D398 /* SocketEnginePacketType.swift in Sources */, 74171E6F1C10CD240062D398 /* SocketAnyEvent.swift in Sources */, + 747BC5991D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */, 74171E9F1C10CD240062D398 /* SocketIOClientOption.swift in Sources */, 74BC45AB1D0C6675008CC431 /* SocketClientManager.swift in Sources */, ); @@ -679,6 +688,7 @@ 74171EB91C10CD240062D398 /* SocketParsable.swift in Sources */, 74171E831C10CD240062D398 /* SocketEnginePacketType.swift in Sources */, 74171E711C10CD240062D398 /* SocketAnyEvent.swift in Sources */, + 747BC59A1D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */, 74171EA11C10CD240062D398 /* SocketIOClientOption.swift in Sources */, 74BC45AC1D0C6675008CC431 /* SocketClientManager.swift in Sources */, ); @@ -691,6 +701,7 @@ 742D150C1CA5794B00BD987D /* SocketObjectiveCTest.m in Sources */, 74321DCB1C2D939A00CF6F43 /* SocketAckManagerTest.swift in Sources */, 74321DCC1C2D939A00CF6F43 /* SocketParserTest.swift in Sources */, + 747BC59F1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift in Sources */, 7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */, 74171EA81C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, 741F39EF1BD025D80026C9CC /* SocketEngineTest.swift in Sources */, @@ -724,6 +735,7 @@ 74171EBB1C10CD240062D398 /* SocketParsable.swift in Sources */, 74171E851C10CD240062D398 /* SocketEnginePacketType.swift in Sources */, 74171E731C10CD240062D398 /* SocketAnyEvent.swift in Sources */, + 747BC59B1D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */, 74171EA31C10CD240062D398 /* SocketIOClientOption.swift in Sources */, 74BC45AD1D0C6675008CC431 /* SocketClientManager.swift in Sources */, ); diff --git a/SocketIO-MacTests/SocketIOClientConfigurationTest.swift b/SocketIO-MacTests/SocketIOClientConfigurationTest.swift new file mode 100644 index 0000000..7c78261 --- /dev/null +++ b/SocketIO-MacTests/SocketIOClientConfigurationTest.swift @@ -0,0 +1,46 @@ +// +// TestSocketIOClientConfiguration.swift +// Socket.IO-Client-Swift +// +// Created by Erik Little on 8/13/16. +// +// + +import XCTest +import SocketIOClientSwift + +class TestSocketIOClientConfiguration: XCTestCase { + var config = [] as SocketIOClientConfiguration + + override func setUp() { + super.setUp() + + config = [.Log(false), .ForceNew(true)] as SocketIOClientConfiguration + } + + func testReplaceSameOption() { + config.insert(.Log(true)) + + XCTAssertEqual(config.count, 2) + + switch config[0] { + case let .Log(log): + XCTAssertTrue(log) + default: + XCTFail() + } + } + + func testIgnoreIfExisting() { + config.insert(.ForceNew(false), replacing: false) + + XCTAssertEqual(config.count, 2) + + switch config[1] { + case let .ForceNew(new): + XCTAssertTrue(new) + default: + XCTFail() + } + } +} diff --git a/SocketIO-MacTests/SocketObjectiveCTest.m b/SocketIO-MacTests/SocketObjectiveCTest.m index b2f7832..cafeff0 100644 --- a/SocketIO-MacTests/SocketObjectiveCTest.m +++ b/SocketIO-MacTests/SocketObjectiveCTest.m @@ -21,7 +21,7 @@ - (void)setUp { [super setUp]; NSURL* url = [[NSURL alloc] initWithString:@"http://localhost"]; - self.socket = [[SocketIOClient alloc] initWithSocketURL:url options:nil]; + self.socket = [[SocketIOClient alloc] initWithSocketURL:url config:nil]; } - (void)testOnSyntax { diff --git a/Source/SocketEngine.swift b/Source/SocketEngine.swift index 0a848a2..b86f42a 100644 --- a/Source/SocketEngine.swift +++ b/Source/SocketEngine.swift @@ -80,7 +80,7 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo private var selfSigned = false private var voipEnabled = false - public init(client: SocketEngineClient, url: NSURL, options: Set) { + public init(client: SocketEngineClient, url: NSURL, options: SocketIOClientConfiguration) { self.client = client self.url = url @@ -127,7 +127,7 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo } public convenience init(client: SocketEngineClient, url: NSURL, options: NSDictionary?) { - self.init(client: client, url: url, options: options?.toSocketOptionsSet() ?? []) + self.init(client: client, url: url, options: options?.toSocketConfiguration() ?? []) } deinit { diff --git a/Source/SocketExtensions.swift b/Source/SocketExtensions.swift index 0cf05b3..f15d3be 100644 --- a/Source/SocketExtensions.swift +++ b/Source/SocketExtensions.swift @@ -89,12 +89,12 @@ extension NSDictionary { } } - func toSocketOptionsSet() -> Set { - var options = Set() + func toSocketConfiguration() -> SocketIOClientConfiguration { + var options = [] as SocketIOClientConfiguration for (rawKey, value) in self { if let key = rawKey as? String, opt = NSDictionary.keyValueToSocketIOClientOption(key, value: value) { - options.insertIgnore(opt) + options.insert(opt) } } @@ -102,14 +102,6 @@ extension NSDictionary { } } -extension Set where Element : ClientOption { - mutating func insertIgnore(element: Element) { - if !contains(element) { - insert(element) - } - } -} - extension String { func toArray() throws -> [AnyObject] { guard let stringData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) else { return [] } diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift index a9d0e47..0adf61c 100644 --- a/Source/SocketIOClient.swift +++ b/Source/SocketIOClient.swift @@ -42,7 +42,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable public var forceNew = false public var nsp = "/" - public var options: Set + public var config: SocketIOClientConfiguration public var reconnects = true public var reconnectWait = 10 public var sid: String? { @@ -67,15 +67,15 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable var waitingPackets = [SocketPacket]() /// Type safe way to create a new SocketIOClient. opts can be omitted - public init(socketURL: NSURL, options: Set = []) { - self.options = options + public init(socketURL: NSURL, config: SocketIOClientConfiguration = []) { + self.config = config self.socketURL = socketURL if socketURL.absoluteString.hasPrefix("https://") { - self.options.insertIgnore(.Secure(true)) + self.config.insert(.Secure(true)) } - for option in options { + for option in config { switch option { case let .Reconnects(reconnects): self.reconnects = reconnects @@ -98,15 +98,15 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable } } - self.options.insertIgnore(.Path("/socket.io/")) + self.config.insert(.Path("/socket.io/"), replacing: false) super.init() } /// Not so type safe way to create a SocketIOClient, meant for Objective-C compatiblity. /// If using Swift it's recommended to use `init(socketURL: NSURL, options: Set)` - public convenience init(socketURL: NSURL, options: NSDictionary?) { - self.init(socketURL: socketURL, options: options?.toSocketOptionsSet() ?? []) + public convenience init(socketURL: NSURL, config: NSDictionary?) { + self.init(socketURL: socketURL, config: config?.toSocketConfiguration() ?? []) } deinit { @@ -117,7 +117,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable private func addEngine() -> SocketEngineSpec { DefaultSocketLogger.Logger.log("Adding engine", type: logType) - engine = SocketEngine(client: self, url: socketURL, options: options) + engine = SocketEngine(client: self, url: socketURL, options: config) return engine! } diff --git a/Source/SocketIOClientConfiguration.swift b/Source/SocketIOClientConfiguration.swift new file mode 100644 index 0000000..c743991 --- /dev/null +++ b/Source/SocketIOClientConfiguration.swift @@ -0,0 +1,107 @@ +// +// SocketIOClientConfiguration.swift +// Socket.IO-Client-Swift +// +// Created by Erik Little on 8/13/16. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +public struct SocketIOClientConfiguration : ArrayLiteralConvertible, CollectionType, MutableCollectionType { + public typealias Element = SocketIOClientOption + public typealias Index = Array.Index + public typealias Generator = Array.Generator + public typealias SubSequence = Array.SubSequence + + private var backingArray = [SocketIOClientOption]() + + public var startIndex: Index { + return backingArray.startIndex + } + + public var endIndex: Index { + return backingArray.endIndex + } + + public var isEmpty: Bool { + return backingArray.isEmpty + } + + public var count: Index.Distance { + return backingArray.count + } + + public var first: Generator.Element? { + return backingArray.first + } + + public subscript(position: Index) -> Generator.Element { + get { + return backingArray[position] + } + + set { + backingArray[position] = newValue + } + } + + public subscript(bounds: Range) -> SubSequence { + get { + return backingArray[bounds] + } + + set { + backingArray[bounds] = newValue + } + } + + public init(arrayLiteral elements: Element...) { + backingArray = elements + } + + public func generate() -> Generator { + return backingArray.generate() + } + + public mutating func insert(element: Element, replacing replace: Bool = true) { + for i in 0.. SubSequence { + return backingArray.prefixUpTo(end) + } + + @warn_unused_result + public func prefixThrough(position: Index) -> SubSequence { + return prefixThrough(position) + } + + @warn_unused_result + public func suffixFrom(start: Index) -> SubSequence { + return backingArray.suffixFrom(start) + } +} diff --git a/Source/SocketIOClientOption.swift b/Source/SocketIOClientOption.swift index bf616ff..512cd05 100644 --- a/Source/SocketIOClientOption.swift +++ b/Source/SocketIOClientOption.swift @@ -24,7 +24,7 @@ import Foundation -protocol ClientOption : CustomStringConvertible, Hashable { +protocol ClientOption : CustomStringConvertible, Equatable { func getSocketIOOptionValue() -> AnyObject } @@ -99,10 +99,6 @@ public enum SocketIOClientOption : ClientOption { return description } - public var hashValue: Int { - return description.hashValue - } - func getSocketIOOptionValue() -> AnyObject { let value: AnyObject From c364f6a83233d3b4fd6616140c3e334d2d740c88 Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 14 Aug 2016 09:58:21 -0400 Subject: [PATCH 07/10] tweaks --- .../SocketIOClientConfigurationTest.swift | 2 +- Source/SocketExtensions.swift | 2 +- Source/SocketIOClient.swift | 7 ++-- Source/SocketPacket.swift | 38 ++++++------------- 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/SocketIO-MacTests/SocketIOClientConfigurationTest.swift b/SocketIO-MacTests/SocketIOClientConfigurationTest.swift index 7c78261..ee5dbdf 100644 --- a/SocketIO-MacTests/SocketIOClientConfigurationTest.swift +++ b/SocketIO-MacTests/SocketIOClientConfigurationTest.swift @@ -15,7 +15,7 @@ class TestSocketIOClientConfiguration: XCTestCase { override func setUp() { super.setUp() - config = [.Log(false), .ForceNew(true)] as SocketIOClientConfiguration + config = [.Log(false), .ForceNew(true)] } func testReplaceSameOption() { diff --git a/Source/SocketExtensions.swift b/Source/SocketExtensions.swift index f15d3be..71a8bd8 100644 --- a/Source/SocketExtensions.swift +++ b/Source/SocketExtensions.swift @@ -36,7 +36,7 @@ extension Array where Element: AnyObject { } extension NSCharacterSet { - class var allowedURLCharacterSet: NSCharacterSet { + static var allowedURLCharacterSet: NSCharacterSet { return NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet } } diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift index 0adf61c..7912615 100644 --- a/Source/SocketIOClient.swift +++ b/Source/SocketIOClient.swift @@ -45,9 +45,6 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable public var config: SocketIOClientConfiguration public var reconnects = true public var reconnectWait = 10 - public var sid: String? { - return nsp + "#" + (engine?.sid ?? "") - } private let ackQueue = dispatch_queue_create("com.socketio.ackQueue", DISPATCH_QUEUE_SERIAL) private let emitQueue = dispatch_queue_create("com.socketio.emitQueue", DISPATCH_QUEUE_SERIAL) @@ -66,6 +63,10 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable var waitingPackets = [SocketPacket]() + public var sid: String? { + return nsp + "#" + (engine?.sid ?? "") + } + /// Type safe way to create a new SocketIOClient. opts can be omitted public init(socketURL: NSURL, config: SocketIOClientConfiguration = []) { self.config = config diff --git a/Source/SocketPacket.swift b/Source/SocketPacket.swift index 6326453..a34691e 100644 --- a/Source/SocketPacket.swift +++ b/Source/SocketPacket.swift @@ -26,6 +26,10 @@ import Foundation struct SocketPacket { + enum PacketType: Int { + case Connect, Disconnect, Event, Ack, Error, BinaryEvent, BinaryAck + } + private let placeholders: Int private static let logType = "SocketPacket" @@ -34,9 +38,8 @@ struct SocketPacket { let id: Int let type: PacketType - enum PacketType: Int { - case Connect, Disconnect, Event, Ack, Error, BinaryEvent, BinaryAck - } + var binary: [NSData] + var data: [AnyObject] var args: [AnyObject] { if type == .Event || type == .BinaryEvent && data.count != 0 { @@ -46,8 +49,6 @@ struct SocketPacket { } } - var binary: [NSData] - var data: [AnyObject] var description: String { return "SocketPacket {type: \(String(type.rawValue)); data: " + "\(String(data)); id: \(id); placeholders: \(placeholders); nsp: \(nsp)}" @@ -110,27 +111,12 @@ struct SocketPacket { private func createPacketString() -> String { let typeString = String(type.rawValue) - let binaryCountString: String - let nspString: String - let idString: String - - if type == .BinaryEvent || type == .BinaryAck { - binaryCountString = typeString + String(binary.count) + "-" - } else { - binaryCountString = typeString - } - - if nsp != "/" { - nspString = binaryCountString + nsp + "," - } else { - nspString = binaryCountString - } - - if id != -1 { - idString = nspString + String(id) - } else { - idString = nspString - } + // Binary count? + let binaryCountString = typeString + (type == .BinaryEvent || type == .BinaryAck ? String(binary.count) + "-" : "") + // Namespace? + let nspString = binaryCountString + (nsp != "/" ? nsp + "," : "") + // Ack number? + let idString = nspString + (id != -1 ? String(id) : "") return completeMessage(idString) } From 07f2ca5f16ff3ee2241df5f17218d5a6ade10d31 Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 14 Aug 2016 11:06:55 -0400 Subject: [PATCH 08/10] rename engine init --- Source/SocketEngine.swift | 6 +++--- Source/SocketIOClient.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/SocketEngine.swift b/Source/SocketEngine.swift index b86f42a..9b3c5e1 100644 --- a/Source/SocketEngine.swift +++ b/Source/SocketEngine.swift @@ -80,11 +80,11 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo private var selfSigned = false private var voipEnabled = false - public init(client: SocketEngineClient, url: NSURL, options: SocketIOClientConfiguration) { + public init(client: SocketEngineClient, url: NSURL, config: SocketIOClientConfiguration) { self.client = client self.url = url - for option in options { + for option in config { switch option { case let .ConnectParams(params): connectParams = params @@ -127,7 +127,7 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo } public convenience init(client: SocketEngineClient, url: NSURL, options: NSDictionary?) { - self.init(client: client, url: url, options: options?.toSocketConfiguration() ?? []) + self.init(client: client, url: url, config: options?.toSocketConfiguration() ?? []) } deinit { diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift index 7912615..3cc5fa4 100644 --- a/Source/SocketIOClient.swift +++ b/Source/SocketIOClient.swift @@ -118,7 +118,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable private func addEngine() -> SocketEngineSpec { DefaultSocketLogger.Logger.log("Adding engine", type: logType) - engine = SocketEngine(client: self, url: socketURL, options: config) + engine = SocketEngine(client: self, url: socketURL, config: config) return engine! } From 518c256cc2dc3bba7e32600acfaddc9da8292dcc Mon Sep 17 00:00:00 2001 From: Derek Clarkson Date: Mon, 15 Aug 2016 12:18:02 +1000 Subject: [PATCH 09/10] Renamed modules to make then consistent. Remove base sources from test compiles. --- .../project.pbxproj | 158 ++++++++---------- SocketIO-MacTests/SocketAckManagerTest.swift | 2 +- SocketIO-MacTests/SocketBasicPacketTest.swift | 2 +- SocketIO-MacTests/SocketEngineTest.swift | 2 +- .../SocketIOClientConfigurationTest.swift | 2 +- .../SocketNamespacePacketTest.swift | 2 +- SocketIO-MacTests/SocketObjectiveCTest.m | 2 +- SocketIO-MacTests/SocketParserTest.swift | 2 +- SocketIO-MacTests/SocketSideEffectTest.swift | 2 +- SocketIO-iOS/{SocketIO-iOS.h => SocketIO.h} | 0 10 files changed, 76 insertions(+), 98 deletions(-) rename SocketIO-iOS/{SocketIO-iOS.h => SocketIO.h} (100%) diff --git a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj index 98a0f57..8ad9641 100644 --- a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj +++ b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj @@ -7,100 +7,70 @@ objects = { /* Begin PBXBuildFile section */ - 572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 572EF2251B51F16C00EEBB58 /* SocketIOClientSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */; }; + 572EF21F1B51F16C00EEBB58 /* SocketIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; }; 572EF23D1B51F18A00EEBB58 /* SocketIO-Mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 572EF2431B51F18A00EEBB58 /* SocketIOClientSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */; }; - 57634A111BD9B46A00E19CD7 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */; }; + 57634A111BD9B46A00E19CD7 /* SocketIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO.h */; settings = {ATTRIBUTES = (Public, ); }; }; 57634A231BD9B46D00E19CD7 /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; }; 57634A2A1BD9B46D00E19CD7 /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; }; 57634A2F1BD9B46D00E19CD7 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; }; 57634A321BD9B46D00E19CD7 /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; }; 57634A3F1BD9B4BF00E19CD7 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57634A161BD9B46A00E19CD7 /* SocketIO.framework */; }; + 6CA08A961D615C040061FD2A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CA08A951D615C040061FD2A /* Security.framework */; }; + 6CA08A981D615C0B0061FD2A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CA08A971D615C0B0061FD2A /* Security.framework */; }; + 6CA08A9A1D615C140061FD2A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CA08A991D615C140061FD2A /* Security.framework */; }; 740CA1201C496EEB00CB98F4 /* SocketEngineWebsocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */; }; 740CA1211C496EF200CB98F4 /* SocketEngineWebsocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */; }; 740CA1221C496EF700CB98F4 /* SocketEngineWebsocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */; }; 74171E631C10CD240062D398 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E501C10CD240062D398 /* SocketAckEmitter.swift */; }; - 74171E641C10CD240062D398 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E501C10CD240062D398 /* SocketAckEmitter.swift */; }; 74171E651C10CD240062D398 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E501C10CD240062D398 /* SocketAckEmitter.swift */; }; 74171E671C10CD240062D398 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E501C10CD240062D398 /* SocketAckEmitter.swift */; }; - 74171E681C10CD240062D398 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E501C10CD240062D398 /* SocketAckEmitter.swift */; }; 74171E691C10CD240062D398 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E511C10CD240062D398 /* SocketAckManager.swift */; }; - 74171E6A1C10CD240062D398 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E511C10CD240062D398 /* SocketAckManager.swift */; }; 74171E6B1C10CD240062D398 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E511C10CD240062D398 /* SocketAckManager.swift */; }; 74171E6D1C10CD240062D398 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E511C10CD240062D398 /* SocketAckManager.swift */; }; - 74171E6E1C10CD240062D398 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E511C10CD240062D398 /* SocketAckManager.swift */; }; 74171E6F1C10CD240062D398 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E521C10CD240062D398 /* SocketAnyEvent.swift */; }; - 74171E701C10CD240062D398 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E521C10CD240062D398 /* SocketAnyEvent.swift */; }; 74171E711C10CD240062D398 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E521C10CD240062D398 /* SocketAnyEvent.swift */; }; 74171E731C10CD240062D398 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E521C10CD240062D398 /* SocketAnyEvent.swift */; }; - 74171E741C10CD240062D398 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E521C10CD240062D398 /* SocketAnyEvent.swift */; }; 74171E751C10CD240062D398 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E531C10CD240062D398 /* SocketEngine.swift */; }; - 74171E761C10CD240062D398 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E531C10CD240062D398 /* SocketEngine.swift */; }; 74171E771C10CD240062D398 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E531C10CD240062D398 /* SocketEngine.swift */; }; 74171E791C10CD240062D398 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E531C10CD240062D398 /* SocketEngine.swift */; }; - 74171E7A1C10CD240062D398 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E531C10CD240062D398 /* SocketEngine.swift */; }; 74171E7B1C10CD240062D398 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E541C10CD240062D398 /* SocketEngineClient.swift */; }; - 74171E7C1C10CD240062D398 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E541C10CD240062D398 /* SocketEngineClient.swift */; }; 74171E7D1C10CD240062D398 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E541C10CD240062D398 /* SocketEngineClient.swift */; }; 74171E7F1C10CD240062D398 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E541C10CD240062D398 /* SocketEngineClient.swift */; }; - 74171E801C10CD240062D398 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E541C10CD240062D398 /* SocketEngineClient.swift */; }; 74171E811C10CD240062D398 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E551C10CD240062D398 /* SocketEnginePacketType.swift */; }; - 74171E821C10CD240062D398 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E551C10CD240062D398 /* SocketEnginePacketType.swift */; }; 74171E831C10CD240062D398 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E551C10CD240062D398 /* SocketEnginePacketType.swift */; }; 74171E851C10CD240062D398 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E551C10CD240062D398 /* SocketEnginePacketType.swift */; }; - 74171E861C10CD240062D398 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E551C10CD240062D398 /* SocketEnginePacketType.swift */; }; 74171E871C10CD240062D398 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E561C10CD240062D398 /* SocketEngineSpec.swift */; }; - 74171E881C10CD240062D398 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E561C10CD240062D398 /* SocketEngineSpec.swift */; }; 74171E891C10CD240062D398 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E561C10CD240062D398 /* SocketEngineSpec.swift */; }; 74171E8B1C10CD240062D398 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E561C10CD240062D398 /* SocketEngineSpec.swift */; }; - 74171E8C1C10CD240062D398 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E561C10CD240062D398 /* SocketEngineSpec.swift */; }; 74171E8D1C10CD240062D398 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E571C10CD240062D398 /* SocketEventHandler.swift */; }; - 74171E8E1C10CD240062D398 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E571C10CD240062D398 /* SocketEventHandler.swift */; }; 74171E8F1C10CD240062D398 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E571C10CD240062D398 /* SocketEventHandler.swift */; }; 74171E911C10CD240062D398 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E571C10CD240062D398 /* SocketEventHandler.swift */; }; - 74171E921C10CD240062D398 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E571C10CD240062D398 /* SocketEventHandler.swift */; }; 74171E991C10CD240062D398 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E591C10CD240062D398 /* SocketIOClient.swift */; }; - 74171E9A1C10CD240062D398 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E591C10CD240062D398 /* SocketIOClient.swift */; }; 74171E9B1C10CD240062D398 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E591C10CD240062D398 /* SocketIOClient.swift */; }; 74171E9D1C10CD240062D398 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E591C10CD240062D398 /* SocketIOClient.swift */; }; - 74171E9E1C10CD240062D398 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E591C10CD240062D398 /* SocketIOClient.swift */; }; 74171E9F1C10CD240062D398 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */; }; - 74171EA01C10CD240062D398 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */; }; 74171EA11C10CD240062D398 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */; }; 74171EA31C10CD240062D398 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */; }; - 74171EA41C10CD240062D398 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */; }; 74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; }; - 74171EA61C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; }; 74171EA71C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; }; - 74171EA81C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; }; 74171EA91C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; }; - 74171EAA1C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; }; 74171EAB1C10CD240062D398 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5C1C10CD240062D398 /* SocketLogger.swift */; }; - 74171EAC1C10CD240062D398 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5C1C10CD240062D398 /* SocketLogger.swift */; }; 74171EAD1C10CD240062D398 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5C1C10CD240062D398 /* SocketLogger.swift */; }; 74171EAF1C10CD240062D398 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5C1C10CD240062D398 /* SocketLogger.swift */; }; - 74171EB01C10CD240062D398 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5C1C10CD240062D398 /* SocketLogger.swift */; }; 74171EB11C10CD240062D398 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5D1C10CD240062D398 /* SocketPacket.swift */; }; - 74171EB21C10CD240062D398 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5D1C10CD240062D398 /* SocketPacket.swift */; }; 74171EB31C10CD240062D398 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5D1C10CD240062D398 /* SocketPacket.swift */; }; 74171EB51C10CD240062D398 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5D1C10CD240062D398 /* SocketPacket.swift */; }; - 74171EB61C10CD240062D398 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5D1C10CD240062D398 /* SocketPacket.swift */; }; 74171EB71C10CD240062D398 /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParsable.swift */; }; - 74171EB81C10CD240062D398 /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParsable.swift */; }; 74171EB91C10CD240062D398 /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParsable.swift */; }; 74171EBB1C10CD240062D398 /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParsable.swift */; }; - 74171EBC1C10CD240062D398 /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParsable.swift */; }; 74171EBD1C10CD240062D398 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5F1C10CD240062D398 /* SocketStringReader.swift */; }; - 74171EBE1C10CD240062D398 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5F1C10CD240062D398 /* SocketStringReader.swift */; }; 74171EBF1C10CD240062D398 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5F1C10CD240062D398 /* SocketStringReader.swift */; }; 74171EC11C10CD240062D398 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5F1C10CD240062D398 /* SocketStringReader.swift */; }; - 74171EC21C10CD240062D398 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5F1C10CD240062D398 /* SocketStringReader.swift */; }; 74171EC31C10CD240062D398 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E601C10CD240062D398 /* SocketTypes.swift */; }; - 74171EC41C10CD240062D398 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E601C10CD240062D398 /* SocketTypes.swift */; }; 74171EC51C10CD240062D398 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E601C10CD240062D398 /* SocketTypes.swift */; }; 74171EC71C10CD240062D398 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E601C10CD240062D398 /* SocketTypes.swift */; }; - 74171EC81C10CD240062D398 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E601C10CD240062D398 /* SocketTypes.swift */; }; 741F39EE1BD025D80026C9CC /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; }; 741F39EF1BD025D80026C9CC /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; }; 7420CB791C49629E00956AA4 /* SocketEnginePollable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7420CB781C49629E00956AA4 /* SocketEnginePollable.swift */; }; @@ -161,17 +131,20 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 572EF2191B51F16C00EEBB58 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 572EF21D1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-iOS.h"; sourceTree = ""; }; + 572EF21E1B51F16C00EEBB58 /* SocketIO.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SocketIO.h; sourceTree = ""; }; 572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - 572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 572EF2381B51F18A00EEBB58 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 572EF23B1B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-Mac.h"; sourceTree = ""; }; 572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-MacTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 572EF2481B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57634A161BD9B46A00E19CD7 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 57634A3B1BD9B46D00E19CD7 /* SocketIO-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6CA08A951D615C040061FD2A /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; + 6CA08A971D615C0B0061FD2A /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + 6CA08A991D615C140061FD2A /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; 740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SocketEngineWebsocket.swift; path = Source/SocketEngineWebsocket.swift; sourceTree = ""; }; 74171E501C10CD240062D398 /* SocketAckEmitter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckEmitter.swift; path = Source/SocketAckEmitter.swift; sourceTree = ""; }; 74171E511C10CD240062D398 /* SocketAckManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckManager.swift; path = Source/SocketAckManager.swift; sourceTree = ""; }; @@ -211,6 +184,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 6CA08A961D615C040061FD2A /* Security.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -218,7 +192,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 572EF2251B51F16C00EEBB58 /* SocketIOClientSwift.framework in Frameworks */, + 572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -226,6 +200,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 6CA08A981D615C0B0061FD2A /* Security.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -233,7 +208,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 572EF2431B51F18A00EEBB58 /* SocketIOClientSwift.framework in Frameworks */, + 572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -241,6 +216,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 6CA08A9A1D615C140061FD2A /* Security.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -258,20 +234,21 @@ 572EF20D1B51F12F00EEBB58 = { isa = PBXGroup; children = ( - 5764DF7B1B51F24A004FF46E /* Source */, + 6CA08A9B1D615C190061FD2A /* Frameworks */, + 572EF21A1B51F16C00EEBB58 /* Products */, 572EF21B1B51F16C00EEBB58 /* SocketIO-iOS */, 572EF2391B51F18A00EEBB58 /* SocketIO-Mac */, 572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */, - 572EF21A1B51F16C00EEBB58 /* Products */, + 5764DF7B1B51F24A004FF46E /* Source */, ); sourceTree = ""; }; 572EF21A1B51F16C00EEBB58 /* Products */ = { isa = PBXGroup; children = ( - 572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */, + 572EF2191B51F16C00EEBB58 /* SocketIO.framework */, 572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */, - 572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */, + 572EF2381B51F18A00EEBB58 /* SocketIO.framework */, 572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */, 57634A161BD9B46A00E19CD7 /* SocketIO.framework */, 57634A3B1BD9B46D00E19CD7 /* SocketIO-tvOSTests.xctest */, @@ -282,7 +259,7 @@ 572EF21B1B51F16C00EEBB58 /* SocketIO-iOS */ = { isa = PBXGroup; children = ( - 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */, + 572EF21E1B51F16C00EEBB58 /* SocketIO.h */, 572EF21C1B51F16C00EEBB58 /* Supporting Files */, ); path = "SocketIO-iOS"; @@ -367,6 +344,40 @@ name = Source; sourceTree = ""; }; + 6CA08A9B1D615C190061FD2A /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6CA08A9E1D615C340061FD2A /* tvOS */, + 6CA08A9D1D615C2C0061FD2A /* Mac */, + 6CA08A9C1D615C270061FD2A /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + 6CA08A9C1D615C270061FD2A /* iOS */ = { + isa = PBXGroup; + children = ( + 6CA08A951D615C040061FD2A /* Security.framework */, + ); + name = iOS; + sourceTree = ""; + }; + 6CA08A9D1D615C2C0061FD2A /* Mac */ = { + isa = PBXGroup; + children = ( + 6CA08A971D615C0B0061FD2A /* Security.framework */, + ); + name = Mac; + sourceTree = ""; + }; + 6CA08A9E1D615C340061FD2A /* tvOS */ = { + isa = PBXGroup; + children = ( + 6CA08A991D615C140061FD2A /* Security.framework */, + ); + name = tvOS; + sourceTree = ""; + }; 74B4AD1B1D09A5C30062A523 /* Websocket */ = { isa = PBXGroup; children = ( @@ -383,7 +394,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */, + 572EF21F1B51F16C00EEBB58 /* SocketIO.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -399,7 +410,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 57634A111BD9B46A00E19CD7 /* SocketIO-iOS.h in Headers */, + 57634A111BD9B46A00E19CD7 /* SocketIO.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -421,7 +432,7 @@ ); name = "SocketIO-iOS"; productName = "SocketIO-iOS"; - productReference = 572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */; + productReference = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; productType = "com.apple.product-type.framework"; }; 572EF2231B51F16C00EEBB58 /* SocketIO-iOSTests */ = { @@ -457,7 +468,7 @@ ); name = "SocketIO-Mac"; productName = "SocketIO-Mac"; - productReference = 572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */; + productReference = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */; productType = "com.apple.product-type.framework"; }; 572EF2411B51F18A00EEBB58 /* SocketIO-MacTests */ = { @@ -641,25 +652,9 @@ buildActionMask = 2147483647; files = ( 7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */, - 74171EA61C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, - 74171E881C10CD240062D398 /* SocketEngineSpec.swift in Sources */, - 74171EA01C10CD240062D398 /* SocketIOClientOption.swift in Sources */, - 74171E701C10CD240062D398 /* SocketAnyEvent.swift in Sources */, - 74171EC41C10CD240062D398 /* SocketTypes.swift in Sources */, - 74171E8E1C10CD240062D398 /* SocketEventHandler.swift in Sources */, - 74171E7C1C10CD240062D398 /* SocketEngineClient.swift in Sources */, - 74171E821C10CD240062D398 /* SocketEnginePacketType.swift in Sources */, - 74171EB21C10CD240062D398 /* SocketPacket.swift in Sources */, 741F39EE1BD025D80026C9CC /* SocketEngineTest.swift in Sources */, - 74171EBE1C10CD240062D398 /* SocketStringReader.swift in Sources */, 74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */, - 74171E6A1C10CD240062D398 /* SocketAckManager.swift in Sources */, - 74171E761C10CD240062D398 /* SocketEngine.swift in Sources */, - 74171E641C10CD240062D398 /* SocketAckEmitter.swift in Sources */, - 74171EB81C10CD240062D398 /* SocketParsable.swift in Sources */, - 74171EAC1C10CD240062D398 /* SocketLogger.swift in Sources */, 7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */, - 74171E9A1C10CD240062D398 /* SocketIOClient.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -703,7 +698,6 @@ 74321DCC1C2D939A00CF6F43 /* SocketParserTest.swift in Sources */, 747BC59F1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift in Sources */, 7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */, - 74171EA81C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, 741F39EF1BD025D80026C9CC /* SocketEngineTest.swift in Sources */, 74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */, 7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */, @@ -746,25 +740,9 @@ buildActionMask = 2147483647; files = ( 57634A231BD9B46D00E19CD7 /* SocketSideEffectTest.swift in Sources */, - 74171EAA1C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, - 74171E8C1C10CD240062D398 /* SocketEngineSpec.swift in Sources */, - 74171EA41C10CD240062D398 /* SocketIOClientOption.swift in Sources */, - 74171E741C10CD240062D398 /* SocketAnyEvent.swift in Sources */, - 74171EC81C10CD240062D398 /* SocketTypes.swift in Sources */, - 74171E921C10CD240062D398 /* SocketEventHandler.swift in Sources */, - 74171E801C10CD240062D398 /* SocketEngineClient.swift in Sources */, - 74171E861C10CD240062D398 /* SocketEnginePacketType.swift in Sources */, - 74171EB61C10CD240062D398 /* SocketPacket.swift in Sources */, 57634A2A1BD9B46D00E19CD7 /* SocketEngineTest.swift in Sources */, - 74171EC21C10CD240062D398 /* SocketStringReader.swift in Sources */, 57634A2F1BD9B46D00E19CD7 /* SocketBasicPacketTest.swift in Sources */, - 74171E6E1C10CD240062D398 /* SocketAckManager.swift in Sources */, - 74171E7A1C10CD240062D398 /* SocketEngine.swift in Sources */, - 74171E681C10CD240062D398 /* SocketAckEmitter.swift in Sources */, - 74171EBC1C10CD240062D398 /* SocketParsable.swift in Sources */, - 74171EB01C10CD240062D398 /* SocketLogger.swift in Sources */, 57634A321BD9B46D00E19CD7 /* SocketNamespacePacketTest.swift in Sources */, - 74171E9E1C10CD240062D398 /* SocketIOClient.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -800,7 +778,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACOSX_DEPLOYMENT_TARGET = 10.10; ONLY_ACTIVE_ARCH = YES; - PRODUCT_NAME = SocketIOClientSwift; + PRODUCT_NAME = SocketIO; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TVOS_DEPLOYMENT_TARGET = 9.0; WATCHOS_DEPLOYMENT_TARGET = 2.0; @@ -815,7 +793,7 @@ ENABLE_BITCODE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACOSX_DEPLOYMENT_TARGET = 10.10; - PRODUCT_NAME = SocketIOClientSwift; + PRODUCT_NAME = SocketIO; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TVOS_DEPLOYMENT_TARGET = 9.0; WATCHOS_DEPLOYMENT_TARGET = 2.0; @@ -970,7 +948,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = "SocketIO-iOSTests/Info.plist"; + INFOPLIST_FILE = "SocketIO-iOS/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = YES; @@ -1015,7 +993,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = "SocketIO-iOSTests/Info.plist"; + INFOPLIST_FILE = "SocketIO-iOS/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; @@ -1385,7 +1363,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = "SocketIO-iOSTests/Info.plist"; + INFOPLIST_FILE = "SocketIO-iOS/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = YES; @@ -1430,7 +1408,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = "SocketIO-iOSTests/Info.plist"; + INFOPLIST_FILE = "SocketIO-iOS/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; diff --git a/SocketIO-MacTests/SocketAckManagerTest.swift b/SocketIO-MacTests/SocketAckManagerTest.swift index 91a2f25..70e7890 100644 --- a/SocketIO-MacTests/SocketAckManagerTest.swift +++ b/SocketIO-MacTests/SocketAckManagerTest.swift @@ -7,7 +7,7 @@ // import XCTest -@testable import SocketIOClientSwift +@testable import SocketIO class SocketAckManagerTest: XCTestCase { var ackManager = SocketAckManager() diff --git a/SocketIO-MacTests/SocketBasicPacketTest.swift b/SocketIO-MacTests/SocketBasicPacketTest.swift index 1161fe3..f8b13eb 100644 --- a/SocketIO-MacTests/SocketBasicPacketTest.swift +++ b/SocketIO-MacTests/SocketBasicPacketTest.swift @@ -7,7 +7,7 @@ // import XCTest -@testable import SocketIOClientSwift +@testable import SocketIO class SocketBasicPacketTest: XCTestCase { let data = "test".dataUsingEncoding(NSUTF8StringEncoding)! diff --git a/SocketIO-MacTests/SocketEngineTest.swift b/SocketIO-MacTests/SocketEngineTest.swift index ec543a1..0e2678c 100644 --- a/SocketIO-MacTests/SocketEngineTest.swift +++ b/SocketIO-MacTests/SocketEngineTest.swift @@ -7,7 +7,7 @@ // import XCTest -@testable import SocketIOClientSwift +@testable import SocketIO class SocketEngineTest: XCTestCase { var client: SocketIOClient! diff --git a/SocketIO-MacTests/SocketIOClientConfigurationTest.swift b/SocketIO-MacTests/SocketIOClientConfigurationTest.swift index ee5dbdf..dc2b720 100644 --- a/SocketIO-MacTests/SocketIOClientConfigurationTest.swift +++ b/SocketIO-MacTests/SocketIOClientConfigurationTest.swift @@ -7,7 +7,7 @@ // import XCTest -import SocketIOClientSwift +import SocketIO class TestSocketIOClientConfiguration: XCTestCase { var config = [] as SocketIOClientConfiguration diff --git a/SocketIO-MacTests/SocketNamespacePacketTest.swift b/SocketIO-MacTests/SocketNamespacePacketTest.swift index 4a235ba..431a62b 100644 --- a/SocketIO-MacTests/SocketNamespacePacketTest.swift +++ b/SocketIO-MacTests/SocketNamespacePacketTest.swift @@ -7,7 +7,7 @@ // import XCTest -@testable import SocketIOClientSwift +@testable import SocketIO class SocketNamespacePacketTest: XCTestCase { let data = "test".dataUsingEncoding(NSUTF8StringEncoding)! diff --git a/SocketIO-MacTests/SocketObjectiveCTest.m b/SocketIO-MacTests/SocketObjectiveCTest.m index cafeff0..1de8192 100644 --- a/SocketIO-MacTests/SocketObjectiveCTest.m +++ b/SocketIO-MacTests/SocketObjectiveCTest.m @@ -8,7 +8,7 @@ // #import -@import SocketIOClientSwift; +@import SocketIO; @interface SocketObjectiveCTest : XCTestCase diff --git a/SocketIO-MacTests/SocketParserTest.swift b/SocketIO-MacTests/SocketParserTest.swift index 7307cc0..a43fdaf 100644 --- a/SocketIO-MacTests/SocketParserTest.swift +++ b/SocketIO-MacTests/SocketParserTest.swift @@ -7,7 +7,7 @@ // import XCTest -@testable import SocketIOClientSwift +@testable import SocketIO class SocketParserTest: XCTestCase { let testSocket = SocketIOClient(socketURL: NSURL()) diff --git a/SocketIO-MacTests/SocketSideEffectTest.swift b/SocketIO-MacTests/SocketSideEffectTest.swift index bae130b..a190680 100644 --- a/SocketIO-MacTests/SocketSideEffectTest.swift +++ b/SocketIO-MacTests/SocketSideEffectTest.swift @@ -7,7 +7,7 @@ // import XCTest -@testable import SocketIOClientSwift +@testable import SocketIO class SocketSideEffectTest: XCTestCase { let data = "test".dataUsingEncoding(NSUTF8StringEncoding)! diff --git a/SocketIO-iOS/SocketIO-iOS.h b/SocketIO-iOS/SocketIO.h similarity index 100% rename from SocketIO-iOS/SocketIO-iOS.h rename to SocketIO-iOS/SocketIO.h From 5e1dc533042fc55630bbfca569971bb3ca7ee4bc Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 14 Aug 2016 23:05:02 -0400 Subject: [PATCH 10/10] update readme --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f08ab7a..010ad0a 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ Socket.IO-client for iOS/OS X. ##Example ```swift +import SocketIO + let socket = SocketIOClient(socketURL: NSURL(string: "http://localhost:8080")!, config: [.Log(true), .ForcePolling(true)]) socket.on("connect") {data, ack in @@ -26,6 +28,7 @@ socket.connect() ##Objective-C Example ```objective-c +@import SocketIO; NSURL* url = [[NSURL alloc] initWithString:@"http://localhost:8080"]; SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{@"log": @YES, @"forcePolling": @YES}]; @@ -115,13 +118,13 @@ Import the module: Swift: ```swift -import SocketIOClientSwift +import SocketIO ``` Objective-C: ```Objective-C -@import SocketIOClientSwift; +@import SocketIO; ``` CocoaSeeds