keep trying
This commit is contained in:
parent
bcaf7ba62d
commit
ecf9336132
@ -100,19 +100,32 @@ extension SocketEngineWebsocket {
|
|||||||
|
|
||||||
ws?.connect()
|
ws?.connect()
|
||||||
#else
|
#else
|
||||||
|
func onConnect(ws: Websocket) {
|
||||||
|
self.ws = ws
|
||||||
|
|
||||||
|
attachWebSocketHandlers()
|
||||||
|
handleWSConnect()
|
||||||
|
}
|
||||||
|
|
||||||
let url = urlWebSocketWithSid
|
let url = urlWebSocketWithSid
|
||||||
do {
|
do {
|
||||||
let socket = try TCPInternetSocket(scheme: url.scheme ?? "http",
|
let socket = try TCPInternetSocket(scheme: url.scheme ?? "http",
|
||||||
hostname: url.host ?? "localhost",
|
hostname: url.host ?? "localhost",
|
||||||
port: Port(url.port ?? 80))
|
port: Port(url.port ?? 80))
|
||||||
let stream: ClientStream = secure ? try TLS.InternetSocket(socket, TLS.Context(.client)) : socket
|
|
||||||
try WebSocket.background(to: urlWebSocketWithSid.absoluteString, using: stream) {[weak self] ws in
|
|
||||||
guard let this = self else { return }
|
|
||||||
|
|
||||||
this.ws = ws
|
if secure {
|
||||||
|
let stream = try TLS.InternetSocket(socket, TLS.Context(.client))
|
||||||
|
try WebSocket.background(to: urlWebSocketWithSid.absoluteString, using: stream) {[weak self] ws in
|
||||||
|
guard let this = self else { return }
|
||||||
|
|
||||||
this.attachWebSocketHandlers()
|
onConnect(ws: ws)
|
||||||
this.handleWSConnect()
|
}
|
||||||
|
} else {
|
||||||
|
try WebSocket.background(to: urlWebSocketWithSid.absoluteString, using: socket) {[weak self] ws in
|
||||||
|
guard let this = self else { return }
|
||||||
|
|
||||||
|
onConnect(ws: ws)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
DefaultSocketLogger.Logger.error("Error connecting socket", type: "SocketEngineWebsocket")
|
DefaultSocketLogger.Logger.error("Error connecting socket", type: "SocketEngineWebsocket")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user