Compare commits

...
5 Commits
Author SHA1 Message Date
Erik 846897157c bump version 2015-07-01 07:07:32 -04:00
Erik a49f8f19cf add extraHeaders option fixes. nuclearace/Socket.IO-Client-Swift#64 2015-07-01 07:05:06 -04:00
Erik 531a9784da make it clear as to what language 2015-06-29 18:13:45 -04:00
Erik c34a660cae update readme 2015-06-29 18:12:46 -04:00
Erik 9484bc9614 update readme 2015-06-29 18:11:33 -04:00
3 changed files with 31 additions and 3 deletions

No files matched your search

+8 -1
View File
@@ -78,12 +78,18 @@ Install pods:
$ pod install
```
Import in your swift file:
Import the module:
Swift:
```swift
import Socket_IO_Client_Swift
```
Objective-C:
```Objective-C
#import <Socket_IO_Client_Swift/Socket_IO_Client_Swift-Swift.h>
```
##API
Constructors
-----------
@@ -104,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
-------
+2 -2
View File
@@ -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
+21
View File
@@ -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)
}