Try to reconnect if the state is different than Offline and Disconnected and Error.
Before that, we would check only if the state was different than Offline but in the case of when Kuzzle go down and you catch the Disconnected event, then do a Disconnect() to clean and a Reconnect() to try and connect again to the Kuzzle instance, WebSocket would not try to reconnect because the state would be set as Offline which would then initialize some goroutine inside the Kuzzle instance as long as we try to reconnect to the Kuzzle instance and get a OnNetworkError. Once connected to the Kuzzle instance those go routine would still be alive.. for nothing. So if you try to to reconnect to Kuzzle in a loop you would have a serious memory leak.
What does this PR do?
Try to reconnect if the state is different than Offline and Disconnected and Error.
Before that, we would check only if the state was different than Offline but in the case of when Kuzzle go down and you catch the
Disconnected
event, then do a Disconnect() to clean and a Reconnect() to try and connect again to the Kuzzle instance, WebSocket would not try to reconnect because the state would be set asOffline
which would then initialize some goroutine inside the Kuzzle instance as long as we try to reconnect to the Kuzzle instance and get a OnNetworkError. Once connected to the Kuzzle instance those go routine would still be alive.. for nothing. So if you try to to reconnect to Kuzzle in a loop you would have a serious memory leak.