refactors
This commit is contained in:
parent
73b042b41e
commit
22030e1153
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
private struct SocketAck : Hashable, Equatable {
|
private struct SocketAck : Hashable {
|
||||||
let ack: Int
|
let ack: Int
|
||||||
var callback: AckCallback!
|
var callback: AckCallback!
|
||||||
var hashValue: Int {
|
var hashValue: Int {
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public final class SocketClientManager : NSObject {
|
|||||||
return sockets.removeValueForKey(label)
|
return sockets.removeValueForKey(label)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func removeSocket(socket socket: SocketIOClient) -> SocketIOClient? {
|
public func removeSocket(socket: SocketIOClient) -> SocketIOClient? {
|
||||||
var returnSocket: SocketIOClient?
|
var returnSocket: SocketIOClient?
|
||||||
|
|
||||||
for (label, dictSocket) in sockets where dictSocket === socket {
|
for (label, dictSocket) in sockets where dictSocket === socket {
|
||||||
|
|||||||
@ -59,6 +59,8 @@ extension SocketEnginePollable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createRequestForPostWithPostWait() -> NSURLRequest {
|
func createRequestForPostWithPostWait() -> NSURLRequest {
|
||||||
|
defer { postWait.removeAll(keepCapacity: true) }
|
||||||
|
|
||||||
var postStr = ""
|
var postStr = ""
|
||||||
|
|
||||||
for packet in postWait {
|
for packet in postWait {
|
||||||
@ -69,18 +71,13 @@ extension SocketEnginePollable {
|
|||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Created POST string: %@", type: "SocketEnginePolling", args: postStr)
|
DefaultSocketLogger.Logger.log("Created POST string: %@", type: "SocketEnginePolling", args: postStr)
|
||||||
|
|
||||||
postWait.removeAll(keepCapacity: false)
|
|
||||||
|
|
||||||
let req = NSMutableURLRequest(URL: urlPollingWithSid)
|
let req = NSMutableURLRequest(URL: urlPollingWithSid)
|
||||||
|
let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
|
||||||
|
|
||||||
addHeaders(req)
|
addHeaders(req)
|
||||||
|
|
||||||
req.HTTPMethod = "POST"
|
req.HTTPMethod = "POST"
|
||||||
req.setValue("text/plain; charset=UTF-8", forHTTPHeaderField: "Content-Type")
|
req.setValue("text/plain; charset=UTF-8", forHTTPHeaderField: "Content-Type")
|
||||||
|
|
||||||
let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding,
|
|
||||||
allowLossyConversion: false)!
|
|
||||||
|
|
||||||
req.HTTPBody = postData
|
req.HTTPBody = postData
|
||||||
req.setValue(String(postData.length), forHTTPHeaderField: "Content-Length")
|
req.setValue(String(postData.length), forHTTPHeaderField: "Content-Length")
|
||||||
|
|
||||||
@ -88,11 +85,10 @@ extension SocketEnginePollable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func doPoll() {
|
public func doPoll() {
|
||||||
if websocket || waitingForPoll || !connected || closed {
|
if websocket || waitingForPoll || !connected || closed { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
waitingForPoll = true
|
waitingForPoll = true
|
||||||
|
|
||||||
let req = NSMutableURLRequest(URL: urlPollingWithSid)
|
let req = NSMutableURLRequest(URL: urlPollingWithSid)
|
||||||
|
|
||||||
addHeaders(req)
|
addHeaders(req)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user