List of usage examples for io.vertx.core.buffer Buffer appendByte
@Fluent
Buffer appendByte(byte b);
From source file:examples.HTTP2Examples.java
License:Open Source License
public void example23(HttpConnection connection) { Buffer data = Buffer.buffer(); for (byte i = 0; i < 8; i++) { data.appendByte(i); }// ww w. j ava 2s . c om connection.ping(data, pong -> { System.out.println("Remote side replied"); }); }
From source file:io.fabric8.msg.jnatsd.routing.Address.java
License:Apache License
public void appendToBuffer(Buffer buffer) { for (int i = 0; i < array.length; i++) { buffer.appendByte((byte) array[i]); }/*from w w w. ja v a2s . c om*/ }
From source file:org.eclipse.hono.authentication.impl.AbstractPlainAuthenticationService.java
License:Open Source License
private String[] readFields(final byte[] buffer) throws CredentialException { List<String> fields = new ArrayList<>(); int pos = 0;/*from www . j ava2s . co m*/ Buffer b = Buffer.buffer(); while (pos < buffer.length) { byte val = buffer[pos]; if (val == 0x00) { fields.add(b.toString(StandardCharsets.UTF_8)); b = Buffer.buffer(); } else { b.appendByte(val); } pos++; } fields.add(b.toString(StandardCharsets.UTF_8)); if (fields.size() != 3) { throw new CredentialException("client provided malformed PLAIN response"); } else if (fields.get(1) == null || fields.get(1).length() == 0) { throw new CredentialException("PLAIN response must contain an authentication ID"); } else if (fields.get(2) == null || fields.get(2).length() == 0) { throw new CredentialException("PLAIN response must contain a password"); } else { return fields.toArray(new String[3]); } }
From source file:shadowsocks.vertxio.ClientHandler.java
License:Apache License
private boolean handleStageAddress() { int bufferLength = mBufferQueue.length(); String addr = null;//from w ww.ja va2 s. co m // Construct the remote header. Buffer remoteHeader = Buffer.buffer(); int addrType = mBufferQueue.getByte(0); if (mConfig.oneTimeAuth) { remoteHeader.appendByte((byte) (addrType | OTA_FLAG)); } else { remoteHeader.appendByte((byte) (addrType)); } if (addrType == ADDR_TYPE_IPV4) { // addr type (1) + ipv4(4) + port(2) if (bufferLength < 7) return false; try { addr = InetAddress.getByAddress(mBufferQueue.getBytes(1, 5)).toString(); } catch (UnknownHostException e) { log.error("UnknownHostException.", e); return true; } remoteHeader.appendBytes(mBufferQueue.getBytes(1, 5)); compactBuffer(5); } else if (addrType == ADDR_TYPE_HOST) { short hostLength = mBufferQueue.getUnsignedByte(1); // addr type(1) + len(1) + host + port(2) if (bufferLength < hostLength + 4) return false; addr = mBufferQueue.getString(2, hostLength + 2); remoteHeader.appendByte((byte) hostLength).appendString(addr); compactBuffer(hostLength + 2); } else { log.warn("Unsupport addr type " + addrType); return true; } int port = mBufferQueue.getUnsignedShort(0); remoteHeader.appendShort((short) port); compactBuffer(2); log.info("Connecting to " + addr + ":" + port); connectToRemote(mConfig.server, mConfig.serverPort, remoteHeader); nextStage(); return false; }