Use guard statements in polling
This commit is contained in:
parent
7cf4d527df
commit
6ca554f4ad
@ -114,9 +114,7 @@ extension SocketEnginePollable {
|
|||||||
///
|
///
|
||||||
/// You shouldn't need to call this directly, the engine should automatically maintain a long-poll request.
|
/// You shouldn't need to call this directly, the engine should automatically maintain a long-poll request.
|
||||||
public func doPoll() {
|
public func doPoll() {
|
||||||
if websocket || waitingForPoll || !connected || closed {
|
guard !websocket && !waitingForPoll && connected && !closed else { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var req = URLRequest(url: urlPollingWithSid)
|
var req = URLRequest(url: urlPollingWithSid)
|
||||||
addHeaders(to: &req)
|
addHeaders(to: &req)
|
||||||
@ -125,9 +123,7 @@ extension SocketEnginePollable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doRequest(for req: URLRequest, callbackWith callback: @escaping (Data?, URLResponse?, Error?) -> Void) {
|
func doRequest(for req: URLRequest, callbackWith callback: @escaping (Data?, URLResponse?, Error?) -> Void) {
|
||||||
if !polling || closed || invalidated || fastUpgrade {
|
guard polling && !closed && !invalidated && !fastUpgrade else { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Doing polling %@ %@", type: "SocketEnginePolling",
|
DefaultSocketLogger.Logger.log("Doing polling %@ %@", type: "SocketEnginePolling",
|
||||||
args: req.httpMethod ?? "", req)
|
args: req.httpMethod ?? "", req)
|
||||||
@ -168,10 +164,10 @@ extension SocketEnginePollable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func flushWaitingForPost() {
|
private func flushWaitingForPost() {
|
||||||
if postWait.count == 0 || !connected {
|
guard postWait.count != 0 && connected else { return }
|
||||||
return
|
guard !websocket else {
|
||||||
} else if websocket {
|
|
||||||
flushWaitingForPostToWebSocket()
|
flushWaitingForPostToWebSocket()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user