/** * Constructor * * @param name the {@code AgentProtocol.getName()}. */ public AgentProtocolClientFilterLayer(String name) { this.sendProtocol = ByteBufferUtils.wrapUTF8("Protocol:" + name).asReadOnlyBuffer(); }
/** * 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); } }
new Object[]{stack().name(), headerAsString, e.getMessage()}); responseOutput = ByteBufferUtils.wrapUTF8("ERROR: Malformed connection header"); if (this.headerOutput.hasRemaining()) { e.getMessage()}); responseOutput = ByteBufferUtils.wrapUTF8(String.format("%s: %s", e instanceof PermanentConnectionRefusalException ? "FATAL" : "ERROR", e.getMessage())); if (this.headerOutput.hasRemaining()) { return; responseOutput = ByteBufferUtils.wrapUTF8("OK"); if (this.headerOutput.hasRemaining()) {