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

View File

@@ -134,10 +134,11 @@ public class NetworkEvents extends EventsBase {
* Response confirming a client was started. * 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. * @param identifier Event ID used for correlation.
*/ */
@AutoResponseResult @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. */ /** WIP (Not working) Request to reconnect a client to a previous address. */
public record Reconnect(long clientId, NetworkingReconnect networkingReconnect, long identifier) public record Reconnect(long clientId, NetworkingReconnect networkingReconnect, long identifier)