@@ -29,6 +29,7 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
2929 public let handleQueue = dispatch_queue_create ( " com.socketio.engineHandleQueue " , DISPATCH_QUEUE_SERIAL)
3030 public let parseQueue = dispatch_queue_create ( " com.socketio.engineParseQueue " , DISPATCH_QUEUE_SERIAL)
3131
32+ public var connectParams : [ String : AnyObject ] ?
3233 public var postWait = [ String] ( )
3334 public var waitingForPoll = false
3435 public var waitingForPost = false
@@ -47,8 +48,8 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
4748 public private( set) var session : NSURLSession ?
4849 public private( set) var sid = " "
4950 public private( set) var socketPath = " /engine.io/ "
50- public private( set) var urlPolling = NSURL ( string : " http://localhost?default= " ) !
51- public private( set) var urlWebSocket = NSURL ( string : " http://localhost?default= " ) !
51+ public private( set) var urlPolling = NSURL ( )
52+ public private( set) var urlWebSocket = NSURL ( )
5253 public private( set) var websocket = false
5354 public private( set) var ws : WebSocket ?
5455
@@ -63,7 +64,6 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
6364 private let logType = " SocketEngine "
6465 private let url : NSURL
6566
66- private var connectParams : [ String : AnyObject ] ?
6767 private var pingInterval : Double ?
6868 private var pingTimeout = 0.0 {
6969 didSet {
@@ -83,6 +83,8 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
8383
8484 for option in options {
8585 switch option {
86+ case let . ConnectParams( params) :
87+ connectParams = params
8688 case let . SessionDelegate( delegate) :
8789 sessionDelegate = delegate
8890 case let . ForcePolling( force) :
@@ -105,6 +107,10 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
105107 continue
106108 }
107109 }
110+
111+ super. init ( )
112+
113+ ( urlPolling, urlWebSocket) = createURLs ( )
108114 }
109115
110116 public convenience init ( client: SocketEngineClient , url: NSURL , options: NSDictionary ? ) {
@@ -199,7 +205,7 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
199205 }
200206 }
201207
202- private func createURLs( params : [ String : AnyObject ] ? ) -> ( NSURL , NSURL ) {
208+ private func createURLs( ) -> ( NSURL , NSURL ) {
203209 if client == nil {
204210 return ( NSURL ( ) , NSURL ( ) )
205211 }
@@ -221,8 +227,8 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
221227 urlWebSocket. scheme = " ws "
222228 }
223229
224- if params != nil {
225- for (key, value) in params ! {
230+ if connectParams != nil {
231+ for (key, value) in connectParams ! {
226232 queryString += " & \( key) = \( value) "
227233 }
228234 }
@@ -370,22 +376,18 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
370376 }
371377 }
372378
373- public func open( opts : [ String : AnyObject ] ? ) {
379+ public func open( ) {
374380 if connected {
375381 DefaultSocketLogger . Logger. error ( " Engine tried opening while connected. This is probably a programming error. "
376382 + " Abandoning open attempt " , type: logType)
377383 return
378384 }
379385
380- connectParams = opts
381-
382386 DefaultSocketLogger . Logger. log ( " Starting engine " , type: logType)
383387 DefaultSocketLogger . Logger. log ( " Handshaking " , type: logType)
384388
385389 resetEngine ( )
386390
387- ( urlPolling, urlWebSocket) = createURLs ( opts)
388-
389391 if forceWebsockets {
390392 polling = false
391393 websocket = true
0 commit comments