Skip to content

Commit d71f817

Browse files
committed
move websocketurl plus sid to computed property
1 parent 228c0c7 commit d71f817

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Source/SocketEngine.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,7 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
243243
}
244244

245245
private func createWebsocketAndConnect() {
246-
let component = NSURLComponents(URL: urlWebSocket, resolvingAgainstBaseURL: false)!
247-
component.query = component.query! + (sid == "" ? "" : "&sid=\(sid)")
248-
249-
ws = WebSocket(url: component.URL!)
246+
ws = WebSocket(url: urlWebSocketWithSid)
250247

251248
if cookies != nil {
252249
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)

Source/SocketEngineSpec.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ extension SocketEngineSpec {
6767
return com.URL!
6868
}
6969

70+
var urlWebSocketWithSid: NSURL {
71+
let com = NSURLComponents(URL: urlWebSocket, resolvingAgainstBaseURL: false)!
72+
com.query = com.query! + (sid == "" ? "" : "&sid=\(sid)")
73+
74+
return com.URL!
75+
}
76+
7077
func createBinaryDataForSend(data: NSData) -> Either<NSData, String> {
7178
if websocket {
7279
var byteArray = [UInt8](count: 1, repeatedValue: 0x4)

Source/SocketIOClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
413413
let id = NSUUID()
414414

415415
let handler = SocketEventHandler(event: event, id: id) {[weak self] data, ack in
416-
guard let this = self else {return}
416+
guard let this = self else { return }
417417
this.off(id: id)
418418
callback(data, ack)
419419
}

0 commit comments

Comments
 (0)