This following snippet of code in the project is creating multiple connections when connecting to high latency servers. The while loop calls self.client?.connect again (thus, creating another websocketclient) if the first call takes more than 200 + self._checksDelay millis to connect/fail
|
if !self.isConnected() { |
|
self.client?.disconnect() |
|
usleep(200_000) |
|
self.client?.connect() |
|
usleep(self._checksDelay) |
|
self.updateLastPoint() |
|
continue |
|
} |
The problem with this busy wait approach is that we don't have a way outside this library code to manage those connections and terminate the duplicates if needed.
I think we Should try to use a Lock before the if !self.isConnected() { check to do this verification only after the connection handshake itself. That way we would have only 2 states possible (connection successful or connection failed), hence avoiding the duplicates
This following snippet of code in the project is creating multiple connections when connecting to high latency servers. The while loop calls
self.client?.connectagain (thus, creating another websocketclient) if the first call takes more than200 + self._checksDelaymillis to connect/failAction-Cable-Swift/Sources/ActionCableSwift/Helpers.swift
Lines 155 to 162 in ebb9986
The problem with this busy wait approach is that we don't have a way outside this library code to manage those connections and terminate the duplicates if needed.
I think we Should try to use a Lock before the
if !self.isConnected() {check to do this verification only after the connection handshake itself. That way we would have only 2 states possible (connection successful or connection failed), hence avoiding the duplicates