Search in sources :

Example 1 with DestroyControllerCommand

use of com.canoo.dp.impl.remoting.commands.DestroyControllerCommand in project dolphin-platform by canoo.

the class DestroyControllerCommandEncoder method decode.

@Override
public DestroyControllerCommand decode(final JsonObject jsonObject) {
    Assert.requireNonNull(jsonObject, "jsonObject");
    try {
        final DestroyControllerCommand command = new DestroyControllerCommand();
        command.setControllerId(getStringElement(jsonObject, CONTROLLER_ID));
        return command;
    } catch (final Exception ex) {
        throw new JsonParseException("Illegal JSON detected", ex);
    }
}
Also used : DestroyControllerCommand(com.canoo.dp.impl.remoting.commands.DestroyControllerCommand) JsonParseException(com.google.gson.JsonParseException) JsonParseException(com.google.gson.JsonParseException)

Example 2 with DestroyControllerCommand

use of com.canoo.dp.impl.remoting.commands.DestroyControllerCommand in project dolphin-platform by canoo.

the class ControllerProxyImpl method destroy.

@Override
public CompletableFuture<Void> destroy() {
    if (destroyed) {
        throw new IllegalStateException("The controller was already destroyed");
    }
    destroyed = true;
    final InternalAttributesBean bean = platformBeanRepository.getInternalAttributesBean();
    final CompletableFuture<Void> ret = new CompletableFuture<>();
    final DestroyControllerCommand destroyControllerCommand = new DestroyControllerCommand();
    destroyControllerCommand.setControllerId(controllerId);
    clientConnector.send(destroyControllerCommand, () -> {
        model = null;
        ret.complete(null);
    });
    return ret;
}
Also used : InternalAttributesBean(com.canoo.dp.impl.remoting.InternalAttributesBean) CompletableFuture(java.util.concurrent.CompletableFuture) DestroyControllerCommand(com.canoo.dp.impl.remoting.commands.DestroyControllerCommand)

Aggregations

DestroyControllerCommand (com.canoo.dp.impl.remoting.commands.DestroyControllerCommand)2 InternalAttributesBean (com.canoo.dp.impl.remoting.InternalAttributesBean)1 JsonParseException (com.google.gson.JsonParseException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1