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;
}
}
}
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)));
}
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);
}
Aggregations