protected void sendClientMessage(ClientMessage resultClientMessage) { resultClientMessage.setCorrelationId(clientMessage.getCorrelationId()); resultClientMessage.addFlag(ClientMessage.BEGIN_AND_END_FLAGS); resultClientMessage.setVersion(ClientMessage.VERSION); final Connection connection = endpoint.getConnection(); // TODO framing not implemented yet, should be split into frames before writing to connection connection.write(resultClientMessage); }
public void sendResponse(ClientEndpoint endpoint, Object response) { if (response instanceof Throwable) { response = ClientExceptionConverters.get(endpoint.getClientType()).convert((Throwable) response); } final Data resultData = response != null ? serializationService.toData(response) : NULL; Connection conn = endpoint.getConnection(); conn.write(new DataAdapter(resultData, serializationService.getSerializationContext())); }
@Override public boolean transmit(Packet packet, Connection connection) { checkNotNull(packet, "Packet can't be null"); if (connection == null) { return false; } return connection.write(packet); }
private boolean send(Packet packet, Address target, SendTask sendTask) { Connection connection = getConnection(target); if (connection != null) { return connection.write(packet); } if (sendTask == null) { sendTask = new SendTask(packet, target); } int retries = sendTask.retries; if (retries < RETRY_NUMBER && ioService.isActive()) { getOrConnect(target, true); // TODO: Caution: may break the order guarantee of the packets sent from the same thread! scheduler.schedule(sendTask, (retries + 1) * DELAY_FACTOR, TimeUnit.MILLISECONDS); return true; } return false; }
@Override public boolean transmit(Packet packet, Connection connection) { return (connection != null && connection.write(packet)); }