From 9484bc96140f308326e1faa53f7006f04ab851a6 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 29 Jun 2015 18:11:33 -0400 Subject: [PATCH 1/5] update readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0345805..125997a 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,10 @@ Import in your swift file: import Socket_IO_Client_Swift ``` +```Objective-C +#import +``` + ##API Constructors ----------- From c34a660cae12f41eaa5d527c522af2d957b2edb4 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 29 Jun 2015 18:12:46 -0400 Subject: [PATCH 2/5] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 125997a..c7006ad 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Install pods: $ pod install ``` -Import in your swift file: +Import the module: ```swift import Socket_IO_Client_Swift From 531a9784dad1e00800c1e25e94578a76418329a5 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 29 Jun 2015 18:13:45 -0400 Subject: [PATCH 3/5] make it clear as to what language --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c7006ad..00f7f5b 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,12 @@ $ pod install Import the module: +Swift: ```swift import Socket_IO_Client_Swift ``` +Objective-C: ```Objective-C #import ``` From a49f8f19cf9c6b963572a8750a116dbcfd269026 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 1 Jul 2015 07:05:06 -0400 Subject: [PATCH 4/5] add extraHeaders option fixes. nuclearace/Socket.IO-Client-Swift#64 --- README.md | 1 + SocketIOClientSwift/SocketEngine.swift | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 00f7f5b..7f61ef1 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,7 @@ Options - `log: Bool` If `true` socket will log debug messages. Default is false. - `sessionDelegate: NSURLSessionDelegate` Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil. - `path: String` - If the server uses a custom path. ex: `"/swift"`. Default is `""` +- `extraHeaders: [String: String]?` - Adds custom headers to the initial request. Default is nil. Methods ------- diff --git a/SocketIOClientSwift/SocketEngine.swift b/SocketIOClientSwift/SocketEngine.swift index f288d28..356f912 100644 --- a/SocketIOClientSwift/SocketEngine.swift +++ b/SocketIOClientSwift/SocketEngine.swift @@ -37,6 +37,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient { private var closed = false private var _connected = false + private var extraHeaders:[String: String]? private var fastUpgrade = false private var forcePolling = false private var forceWebsockets = false @@ -109,6 +110,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient { cookies = opts?["cookies"] as? [NSHTTPCookie] log = opts?["log"] as? Bool ?? false socketPath = opts?["path"] as? String ?? "" + extraHeaders = opts?["extraHeaders"] as? [String: String] } deinit { @@ -194,6 +196,13 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient { private func createWebsocket(andConnect connect:Bool) { ws = WebSocket(url: NSURL(string: urlWebSocket! + "&sid=\(sid)")!, cookies: cookies) + + if extraHeaders != nil { + for (headerName, value) in extraHeaders! { + ws?.headers[headerName] = value + } + } + ws?.queue = handleQueue ws?.delegate = self @@ -229,6 +238,12 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient { req.allHTTPHeaderFields = headers } + if extraHeaders != nil { + for (headerName, value) in extraHeaders! { + req.setValue(value, forHTTPHeaderField: headerName) + } + } + doRequest(req) } @@ -477,6 +492,12 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient { reqPolling.allHTTPHeaderFields = headers } + if extraHeaders != nil { + for (headerName, value) in extraHeaders! { + reqPolling.setValue(value, forHTTPHeaderField: headerName) + } + } + doRequest(reqPolling) } From 846897157c22c2d593cf2cee96a82c54e3b4f7f0 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 1 Jul 2015 07:07:32 -0400 Subject: [PATCH 5/5] bump version --- Socket.IO-Client-Swift.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index b2e4519..1848cb9 100644 --- a/Socket.IO-Client-Swift.podspec +++ b/Socket.IO-Client-Swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Socket.IO-Client-Swift" - s.version = "2.3.6" + s.version = "2.3.7" s.summary = "Socket.IO-client for iOS and OS X" s.description = <<-DESC Socket.IO-client for iOS and OS X. @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.author = { "Erik" => "nuclear.ace@gmail.com" } s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.10' - s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v2.3.6' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v2.3.7' } s.source_files = "SocketIOClientSwift/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files