move websocketurl plus sid to computed property
This commit is contained in:
parent
228c0c7c9b
commit
d71f81745e
@ -243,10 +243,7 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func createWebsocketAndConnect() {
|
private func createWebsocketAndConnect() {
|
||||||
let component = NSURLComponents(URL: urlWebSocket, resolvingAgainstBaseURL: false)!
|
ws = WebSocket(url: urlWebSocketWithSid)
|
||||||
component.query = component.query! + (sid == "" ? "" : "&sid=\(sid)")
|
|
||||||
|
|
||||||
ws = WebSocket(url: component.URL!)
|
|
||||||
|
|
||||||
if cookies != nil {
|
if cookies != nil {
|
||||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||||
|
|||||||
@ -67,6 +67,13 @@ extension SocketEngineSpec {
|
|||||||
return com.URL!
|
return com.URL!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var urlWebSocketWithSid: NSURL {
|
||||||
|
let com = NSURLComponents(URL: urlWebSocket, resolvingAgainstBaseURL: false)!
|
||||||
|
com.query = com.query! + (sid == "" ? "" : "&sid=\(sid)")
|
||||||
|
|
||||||
|
return com.URL!
|
||||||
|
}
|
||||||
|
|
||||||
func createBinaryDataForSend(data: NSData) -> Either<NSData, String> {
|
func createBinaryDataForSend(data: NSData) -> Either<NSData, String> {
|
||||||
if websocket {
|
if websocket {
|
||||||
var byteArray = [UInt8](count: 1, repeatedValue: 0x4)
|
var byteArray = [UInt8](count: 1, repeatedValue: 0x4)
|
||||||
|
|||||||
@ -413,7 +413,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
let id = NSUUID()
|
let id = NSUUID()
|
||||||
|
|
||||||
let handler = SocketEventHandler(event: event, id: id) {[weak self] data, ack in
|
let handler = SocketEventHandler(event: event, id: id) {[weak self] data, ack in
|
||||||
guard let this = self else {return}
|
guard let this = self else { return }
|
||||||
this.off(id: id)
|
this.off(id: id)
|
||||||
callback(data, ack)
|
callback(data, ack)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user