private void openConnection(final OpenConnection command) { checkConnectionNotNull(); final ConnectionOpened connectionOpened = ConnectionOpened.of(command.getConnectionId(), command.getDittoHeaders()); final ActorRef origin = getSender(); final ActorRef self = getSelf(); persistEvent(connectionOpened, persistedEvent -> { restoreConnection(connection.toBuilder().connectionStatus(ConnectionStatus.OPEN).build()); askClientActor(command, response -> { final ConnectivityCommandResponse commandResponse = OpenConnectionResponse.of(connectionId, command.getDittoHeaders()); final PerformTask performTask = new PerformTask("open connection", subscribeForEventsAndScheduleResponse(commandResponse, origin)); self.tell(performTask, ActorRef.noSender()); }, error -> handleException("open-connection", origin, error) ); }); }
private void openConnection(final OpenConnection command) { checkConnectionNotNull(); final ConnectionOpened connectionOpened = ConnectionOpened.of(command.getConnectionId(), command.getDittoHeaders()); final ActorRef origin = getSender(); final ActorRef self = getSelf(); persistEvent(connectionOpened, persistedEvent -> { restoreConnection(connection.toBuilder().connectionStatus(ConnectionStatus.OPEN).build()); askClientActor(command, response -> { final ConnectivityCommandResponse commandResponse = OpenConnectionResponse.of(connectionId, command.getDittoHeaders()); final PerformTask performTask = new PerformTask("open connection", subscribeForEventsAndScheduleResponse(commandResponse, origin)); self.tell(performTask, ActorRef.noSender()); }, error -> handleException("open-connection", origin, error) ); }); }
restoreConnection(connection.toBuilder().connectionStatus(ConnectionStatus.CLOSED).build());
restoreConnection(connection.toBuilder().connectionStatus(ConnectionStatus.CLOSED).build());
.match(ConnectionCreated.class, event -> restoreConnection(event.getConnection())) .match(ConnectionModified.class, event -> restoreConnection(event.getConnection())) .match(ConnectionOpened.class, event -> restoreConnection(connection != null ? connection.toBuilder() .connectionStatus(ConnectionStatus.OPEN).build() : null)) .match(ConnectionClosed.class, event -> restoreConnection(connection != null ? connection.toBuilder() .connectionStatus(ConnectionStatus.CLOSED).build() : null)) .match(ConnectionDeleted.class, event -> restoreConnection(null))
.match(ConnectionCreated.class, event -> restoreConnection(event.getConnection())) .match(ConnectionModified.class, event -> restoreConnection(event.getConnection())) .match(ConnectionOpened.class, event -> restoreConnection(connection != null ? connection.toBuilder() .connectionStatus(ConnectionStatus.OPEN).build() : null)) .match(ConnectionClosed.class, event -> restoreConnection(connection != null ? connection.toBuilder() .connectionStatus(ConnectionStatus.CLOSED).build() : null)) .match(ConnectionDeleted.class, event -> restoreConnection(null))