Fixed hundreds of small issues, code improvements, typos, ...

This commit is contained in:
2025-01-16 00:25:23 +01:00
parent ace34fc0e8
commit 0ffe3198e6
44 changed files with 331 additions and 351 deletions

View File

@@ -127,31 +127,34 @@ public abstract class AbstractClientWS implements AbstractWS {
private void connect() {
synchronized (socket) {
isConnecting = true;
HttpClient.newHttpClient()
.newWebSocketBuilder()
.connectTimeout(Duration.ofSeconds(5))
.buildAsync(uri, receiveListener)
.whenCompleteAsync((ws, ex) -> {
synchronized (socket) {
isConnecting = false;
if (ws != null) {
// the value may already been set by the onOpen method of the receiveListener
// but just in case, we do it here too
socket.set(ws);
return;
try (HttpClient cl = HttpClient.newHttpClient()) {
cl.newWebSocketBuilder()
.connectTimeout(Duration.ofSeconds(5))
.buildAsync(uri, receiveListener)
.whenCompleteAsync((ws, ex) -> {
synchronized (socket) {
isConnecting = false;
if (ws != null) {
// the value may already been set by the onOpen method of the receiveListener
// but just in case, we do it here too
socket.set(ws);
return;
}
}
}
if (ex instanceof CompletionException)
ex = ex.getCause();
if (ex instanceof IOException) {
reconnectIfNecessary();
log("Unable to connect. Trying again...: " + ex);
}
else {
autoReconnect = false;
logError("Error connecting (not trying to reconnect even if asked)", ex);
}
});
if (ex instanceof CompletionException)
ex = ex.getCause();
if (ex instanceof IOException) {
reconnectIfNecessary();
log("Unable to connect. Trying again...: " + ex);
}
else {
autoReconnect = false;
logError("Error connecting (not trying to reconnect even if asked)", ex);
}
});
}
}
}