Search in sources :

Example 41 with Command

use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.

the class AbstractClientConnector method commandProcessing.

protected void commandProcessing() {
    boolean longPollingActivated = false;
    while (connectedFlag.get()) {
        try {
            final List<CommandAndHandler> toProcess = commandBatcher.getWaitingBatches().getVal();
            List<Command> commands = new ArrayList<>();
            for (CommandAndHandler c : toProcess) {
                commands.add(c.getCommand());
            }
            if (LOG.isDebugEnabled()) {
                StringBuffer buffer = new StringBuffer();
                for (Command command : commands) {
                    buffer.append(command.getClass().getSimpleName());
                    buffer.append(", ");
                }
                LOG.trace("Sending {} commands to server: {}", commands.size(), buffer.substring(0, buffer.length() - 2));
            } else {
                LOG.trace("Sending {} commands to server", commands.size());
            }
            final List<? extends Command> answers = transmit(commands);
            uiExecutor.execute(new Runnable() {

                @Override
                public void run() {
                    processResults(answers, toProcess);
                }
            });
        } catch (Exception e) {
            if (connectedFlag.get()) {
                handleError(e);
            } else {
                LOG.warn("Remoting error based on broken connection in parallel request", e);
            }
        }
        if (!longPollingActivated && useLongPolling.get()) {
            uiExecutor.execute(new Runnable() {

                @Override
                public void run() {
                    listen();
                }
            });
            longPollingActivated = true;
        }
    }
}
Also used : StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand) InterruptLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) ArrayList(java.util.ArrayList) DolphinRemotingException(com.canoo.platform.remoting.DolphinRemotingException)

Example 42 with Command

use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.

the class DolphinTestClientConnector method send.

@Override
public void send(Command command, OnFinishedHandler callback) {
    List<Command> answer = transmit(new ArrayList<>(Arrays.asList(command)));
    CommandAndHandler handler = new CommandAndHandler(command, callback);
    processResults(answer, new ArrayList<>(Arrays.asList(handler)));
}
Also used : StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) CommandAndHandler(com.canoo.dp.impl.client.legacy.communication.CommandAndHandler)

Example 43 with Command

use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.

the class DolphinTestClientConnector method transmit.

@Override
protected List<Command> transmit(List<Command> commands) {
    ArrayList<Command> realCommands = new ArrayList<>(commands);
    realCommands.add(new StartLongPollCommand());
    return communicationFunction.apply(commands);
}
Also used : StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) ArrayList(java.util.ArrayList) StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand)

Aggregations

Command (com.canoo.dp.impl.remoting.legacy.communication.Command)43 CreatePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand)25 ValueChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand)23 Test (org.testng.annotations.Test)22 EmptyCommand (com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand)19 CallActionCommand (com.canoo.dp.impl.remoting.commands.CallActionCommand)18 StartLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand)10 InterruptLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand)8 ChangeAttributeMetadataCommand (com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand)8 ArrayList (java.util.ArrayList)8 PresentationModelDeletedCommand (com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand)7 CreateContextCommand (com.canoo.dp.impl.remoting.commands.CreateContextCommand)5 LinkedList (java.util.LinkedList)5 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)4 ClientAttribute (com.canoo.dp.impl.client.legacy.ClientAttribute)3 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)3 DestroyContextCommand (com.canoo.dp.impl.remoting.commands.DestroyContextCommand)3 AttributeMetadataChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.AttributeMetadataChangedCommand)3 DeletePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.DeletePresentationModelCommand)3 CommandHandler (com.canoo.dp.impl.server.legacy.communication.CommandHandler)3