List of usage examples for io.netty.buffer ByteBuf readBytes
public abstract ByteBuf readBytes(ByteBuffer dst);
From source file:io.hydramq.core.type.converters.ByteArrayConverter.java
License:Open Source License
@Override public byte[] read(final ConversionContext context, final ByteBuf buffer) { byte[] bytes = new byte[buffer.readInt()]; buffer.readBytes(bytes); return bytes; }
From source file:io.jsql.mysql.mysql.ErrorPacket.java
License:Open Source License
public byte[] writeToBytes2() { ByteBuf buffer = Unpooled.buffer(calcPacketSize() + 4); int size = calcPacketSize(); MBufferUtil.writeUB3(buffer, size);/*from w ww . j a v a 2 s .c o m*/ buffer.writeByte(packetId); buffer.writeByte(fieldCount); MBufferUtil.writeUB2(buffer, errno); buffer.writeByte(mark); buffer.writeBytes(sqlState); if (message != null) { buffer.writeBytes(message); } byte[] data = new byte[buffer.readableBytes()]; buffer.readBytes(data); buffer.release(); return data; }
From source file:io.liveoak.container.protocols.ProtocolDetector.java
License:Open Source License
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { int nonNewlineBytes = in.bytesBefore((byte) '\n'); in.markReaderIndex();/*from w w w . j a v a2s. com*/ if (nonNewlineBytes > 0) { ByteBuf lineBuffer = in.readBytes(nonNewlineBytes); String line = lineBuffer.toString(UTF_8); //SslHandler sslHandler = context.getPipeline().writeState( SslHandler.class ); in.resetReaderIndex(); ByteBuf fullBuffer = in.readBytes(super.actualReadableBytes()); if (line.startsWith("CONNECT") || line.startsWith("STOMP")) { this.configurator.switchToPureStomp(ctx.pipeline()); } else { this.configurator.switchToHttpWebSockets(ctx.pipeline()); } ctx.pipeline().fireChannelRead(fullBuffer); } }
From source file:io.liveoak.stomp.common.StompFrameDecoder.java
License:Open Source License
protected ByteBuf readUntilNull(ByteBuf buffer) { int nonNullBytes = buffer.bytesBefore((byte) 0x00); ByteBuf content = null;/* w w w . j a va2 s .c om*/ if (nonNullBytes == 0) { content = Unpooled.EMPTY_BUFFER; } else { content = buffer.readBytes(nonNullBytes); } buffer.readByte(); return content; }
From source file:io.liveoak.stomp.common.StompFrameDecoder.java
License:Open Source License
protected ByteBuf readUntil(ByteBuf buffer, int len) { if (buffer.readableBytes() < (len + 1)) { return null; }/*from w w w.java2s . c o m*/ ByteBuf content = buffer.readBytes(len); buffer.readByte(); return content; }