This commit is contained in:
Erik 2015-04-27 09:00:57 -04:00
parent ef39651bfa
commit 918f176c56
3 changed files with 16 additions and 5 deletions

View File

@ -97,6 +97,7 @@ Options
- `cookies: [NSHTTPCookie]?` An array of NSHTTPCookies. Passed during the handshake. Default is nil. - `cookies: [NSHTTPCookie]?` An array of NSHTTPCookies. Passed during the handshake. Default is nil.
- `log: Bool` If `true` socket will log debug messages. Default is false. - `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. - `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 `""`
Methods Methods
------- -------

View File

@ -68,6 +68,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
return self._polling return self._polling
} }
var sid = "" var sid = ""
var socketPath = ""
var urlPolling:String? var urlPolling:String?
var urlWebSocket:String? var urlWebSocket:String?
var websocket:Bool { var websocket:Bool {
@ -94,13 +95,14 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
} }
public init(client:SocketEngineClient, forcePolling:Bool, public init(client:SocketEngineClient, forcePolling:Bool,
forceWebsockets:Bool, withCookies cookies:[NSHTTPCookie]?, logging:Bool, forceWebsockets:Bool, cookies:[NSHTTPCookie]?, logging:Bool,
withSessionDelegate sessionDelegate:NSURLSessionDelegate?) { sessionDelegate:NSURLSessionDelegate?, path:String) {
self.client = client self.client = client
self.forcePolling = forcePolling self.forcePolling = forcePolling
self.forceWebsockets = forceWebsockets self.forceWebsockets = forceWebsockets
self.cookies = cookies self.cookies = cookies
self.log = logging self.log = logging
self.socketPath = path
self.session = NSURLSession(configuration: NSURLSessionConfiguration.ephemeralSessionConfiguration(), self.session = NSURLSession(configuration: NSURLSessionConfiguration.ephemeralSessionConfiguration(),
delegate: sessionDelegate, delegateQueue: self.workQueue) delegate: sessionDelegate, delegateQueue: self.workQueue)
} }
@ -146,7 +148,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
return ("", "") return ("", "")
} }
var url = "\(self.client!.socketURL)/socket.io/?transport=" var url = "\(self.client!.socketURL)\(self.socketPath)/socket.io/?transport="
var urlPolling:String var urlPolling:String
var urlWebSocket:String var urlWebSocket:String

View File

@ -75,6 +75,8 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
public var sid:String? { public var sid:String? {
return self._sid return self._sid
} }
public var socketPath = ""
/** /**
Create a new SocketIOClient. opts can be omitted Create a new SocketIOClient. opts can be omitted
@ -103,6 +105,10 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
self.log = log self.log = log
} }
if let path = opts!["path"] as? String {
self.socketPath = path
}
if let polling = opts!["forcePolling"] as? Bool { if let polling = opts!["forcePolling"] as? Bool {
self.forcePolling = polling self.forcePolling = polling
} }
@ -153,9 +159,11 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
self.engine = SocketEngine(client: self, self.engine = SocketEngine(client: self,
forcePolling: self.forcePolling, forcePolling: self.forcePolling,
forceWebsockets: self.forceWebsockets, forceWebsockets: self.forceWebsockets,
withCookies: self.cookies, cookies: self.cookies,
logging: self.log, logging: self.log,
withSessionDelegate: self.sessionDelegate) sessionDelegate: self.sessionDelegate,
path: self.socketPath
)
} }
/** /**