/** * {@inheritDoc} */ @Override public void doSend(@Nonnull ByteBuffer message) throws IOException { messages.add(ByteBufferUtils.duplicate(message)); if (State.CREDENTAILS_AVAILABLE.equals(state)) { processQueuedWrites(); } }
/** * Constructor * * @param name the {@code AgentProtocol.getName()}. */ public AgentProtocolClientFilterLayer(String name) { this.sendProtocol = ByteBufferUtils.wrapUTF8("Protocol:" + name).asReadOnlyBuffer(); }
@Override public void doSend(@NonNull ByteBuffer data) throws IOException { synchronized (lock) { while (data.hasRemaining()) { if (batch.hasRemaining()) { ByteBufferUtils.put(data, batch); } if (!batch.hasRemaining()) { batch.flip(); while (batch.hasRemaining()) { next().doSend(batch); } batch.clear(); } } } }
ByteBufferUtils.put(data, headerInputLength); if (headerInputLength.hasRemaining()) { if (LOGGER.isLoggable(Level.FINEST)) { ByteBufferUtils.put(data, headerInputContent); if (headerInputContent.hasRemaining()) { if (LOGGER.isLoggable(Level.FINEST)) { responseOutput = ByteBufferUtils.wrapUTF8("ERROR: Malformed connection header"); if (this.headerOutput.hasRemaining()) { responseOutput = ByteBufferUtils.wrapUTF8(String.format("%s: %s", e instanceof PermanentConnectionRefusalException ? "FATAL" : "ERROR", e.getMessage())); if (this.headerOutput.hasRemaining()) { responseOutput = ByteBufferUtils.wrapUTF8("OK"); if (this.headerOutput.hasRemaining()) { ByteBufferUtils.put(data, abortConfirmationInput); ByteBufferUtils.put(data, responseInputLength); if (responseInputLength.hasRemaining()) { return; ByteBufferUtils.put(data, responseInputContent); if (responseInputContent.hasRemaining()) { if (LOGGER.isLoggable(Level.FINEST)) {
tempBuffer = previous = ByteBufferUtils.accumulate(readBuffer, previous); } else { tempBuffer = readBuffer; previous = ByteBufferUtils.duplicate(tempBuffer); } else { previous = null;
ByteBufferUtils.put(data, recvAck); if (recvAck.hasRemaining()) { if (!receivedPartialAck()) {
/** * Constructor using a custom acknowledgement string. * * @param ack the acknowledgement string. */ public AckFilterLayer(String ack) { this.sendAck = ByteBufferUtils.wrapUTF8(ack).asReadOnlyBuffer(); this.recvAck = ByteBuffer.allocate(sendAck.capacity()); }
/** * Constructor. * * @param headers Our headers to send. * @param listener Our listener to decide the response to the remote headers. */ public ConnectionHeadersFilterLayer(Map<String, String> headers, Listener listener) { this.headerOutput = ByteBufferUtils.wrapUTF8(ConnectionHeaders.toString(headers)); this.responseOutput = null; this.listener = listener; this.headerInputLength = ByteBuffer.allocate(2); this.headerInputContent = null; }
/** * {@inheritDoc} */ @Override public void start() throws IOException { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = AnonymousClassWarnings.checkingObjectOutputStream(BinarySafeStream.wrap(bos)); try { oos.writeObject(new Capability()); } finally { oos.close(); } ByteBuffer buffer = ByteBufferUtils.wrapUTF8(bos.toString("US-ASCII")); write(buffer); } catch (IOException e) { futureChannel.setException(e); } }