Skip to content

Commit

Permalink
fix: edge case null websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
koraykoska committed Aug 14, 2023
1 parent c705625 commit c79e692
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sources/libwebsockets/WebsocketClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,16 @@ public class WebsocketClient: WebsocketConnection {
}

// Connect
websocket = lws_client_connect_via_info(&lwsCCInfo)
guard let websocket = lws_client_connect_via_info(&lwsCCInfo) else {
eventLoop.execute {
if let onConnect = self.onConnect {
onConnect.fail(Error.connectionError(description: "lws_client_connect_via_info failed"))
self.onConnect = nil
}
}
return
}
self.websocket = websocket

// Polling of Events, including connection success
scheduleServiceCall()
Expand Down

0 comments on commit c79e692

Please sign in to comment.