Fixed event bug

This commit is contained in:
lieght
2025-10-15 03:26:19 +02:00
parent dc81d9c3ca
commit bc6182e29a
2 changed files with 6 additions and 4 deletions

View File

@@ -40,7 +40,7 @@ public class NetworkingClientManager implements org.toop.framework.networking.in
networkingClient.connect(id, host, port);
networkClients.put(id, networkingClient);
logger.info("New client started successfully for {}:{}", host, port);
new EventFlow().addPostEvent(new NetworkEvents.StartClientResponse(id, id)).postEvent();
new EventFlow().addPostEvent(new NetworkEvents.StartClientResponse(id, false, id)).postEvent();
scheduler.shutdown();
} catch (CouldNotConnectException e) {
attempts++;
@@ -50,11 +50,12 @@ public class NetworkingClientManager implements org.toop.framework.networking.in
scheduler.schedule(this, networkingReconnect.timeout(), networkingReconnect.timeUnit());
} else {
logger.error("Failed to start client for {}:{} after {} attempts", host, port, attempts);
new EventFlow().addPostEvent(new NetworkEvents.StartClientResponse(-1, id)).postEvent();
new EventFlow().addPostEvent(new NetworkEvents.StartClientResponse(-1, false, id)).postEvent();
scheduler.shutdown();
}
} catch (Exception e) {
logger.error("Unexpected exception during startClient", e);
new EventFlow().addPostEvent(new NetworkEvents.StartClientResponse(-1, false, id)).postEvent();
scheduler.shutdown();
}
}

View File

@@ -133,11 +133,12 @@ public class NetworkEvents extends EventsBase {
/**
* Response confirming a client was started.
*
* @param clientId The client ID assigned to the new connection.
* @param clientId The client ID assigned to the new connection.
* @param successful If successfully connected or not. If not clientId will also be -1.
* @param identifier Event ID used for correlation.
*/
@AutoResponseResult
public record StartClientResponse(long clientId, long identifier) implements ResponseToUniqueEvent {}
public record StartClientResponse(long clientId, boolean successful, long identifier) implements ResponseToUniqueEvent {}
/** WIP (Not working) Request to reconnect a client to a previous address. */
public record Reconnect(long clientId, NetworkingReconnect networkingReconnect, long identifier)