Java Code Examples for io.netty.buffer.ByteBufInputStream#readInt()
The following examples show how to use
io.netty.buffer.ByteBufInputStream#readInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WireCommands.java From pravega with Apache License 2.0 | 6 votes |
public static WireCommand readFrom(ByteBufInputStream in, int length) throws IOException { long requestId = in.readLong(); String segment = in.readUTF(); String delegationToken = in.readUTF(); int suggestedEntryCount = in.readInt(); int dataLength = in.readInt(); if (length < dataLength + Long.BYTES + segment.getBytes(UTF_8).length + delegationToken.getBytes(UTF_8).length + 2 * Integer.BYTES ) { throw new InvalidMessageException("Was expecting length: " + length + " but found: " + dataLength); } byte[] continuationToken = new byte[dataLength]; in.readFully(continuationToken); return new ReadTableEntries(requestId, segment, delegationToken, suggestedEntryCount, wrappedBuffer(continuationToken)); }
Example 2
Source File: MalmoMod.java From malmo with MIT License | 5 votes |
/** Read a UTF8 string that could potentially be larger than 64k<br> * The ByteBufInputStream.readUTF() and writeUTF() calls use the first two bytes of the message * to encode the length of the string, which limits the string length to 64k. * This method gets around that limitation by using a four byte header. * @param bbis ByteBufInputStream we are reading from * @return the (potentially large) string we read * @throws IOException */ private String readLargeUTF(ByteBufInputStream bbis) throws IOException { int length = bbis.readInt(); if (length == 0) return ""; byte[] data = new byte[length]; int length_read = bbis.read(data, 0, length); if (length_read != length) throw new IOException("Failed to read whole message"); return new String(data, "utf-8"); }
Example 3
Source File: WireCommands.java From pravega with Apache License 2.0 | 5 votes |
public static WireCommand readFrom(ByteBufInputStream in, int length) throws IOException { String segment = in.readUTF(); long offset = in.readLong(); int suggestedLength = in.readInt(); String delegationToken = in.readUTF(); long requestId = in.available() >= Long.BYTES ? in.readLong() : -1L; return new ReadSegment(segment, offset, suggestedLength, delegationToken, requestId); }
Example 4
Source File: WireCommands.java From pravega with Apache License 2.0 | 5 votes |
public static WireCommand readFrom(ByteBufInputStream in, int length) throws IOException { long requestId = in.readLong(); String serverStackTrace = (in.available() > 0) ? in.readUTF() : EMPTY_STACK_TRACE; // errorCode is a new field and wasn't present earlier. Doing this to allow it to work with older clients. int errorCode = in.available() >= Integer.BYTES ? in.readInt() : -1; return new AuthTokenCheckFailed(requestId, serverStackTrace, ErrorCode.valueOf(errorCode)); }
Example 5
Source File: WireCommands.java From pravega with Apache License 2.0 | 5 votes |
public static WireCommand readFrom(ByteBufInputStream in, int length) throws IOException { long requestId = in.readLong(); String segment = in.readUTF(); String delegationToken = in.readUTF(); int suggestedKeyCount = in.readInt(); int dataLength = in.readInt(); if (length < dataLength + Long.BYTES + segment.getBytes(UTF_8).length + delegationToken.getBytes(UTF_8).length + 2 * Integer.BYTES) { throw new InvalidMessageException("Was expecting length: " + length + " but found: " + dataLength); } byte[] continuationToken = new byte[dataLength]; in.readFully(continuationToken); return new ReadTableKeys(requestId, segment, delegationToken, suggestedKeyCount, wrappedBuffer(continuationToken)); }
Example 6
Source File: WireCommands.java From pravega with Apache License 2.0 | 5 votes |
public static WireCommand readFrom(ByteBufInputStream in, int length) throws IOException { long requestId = in.readLong(); String segment = in.readUTF(); String delegationToken = in.readUTF(); long fromVersion = in.readLong(); int suggestedEntryCount = in.readInt(); return new ReadTableEntriesDelta(requestId, segment, delegationToken, fromVersion, suggestedEntryCount); }
Example 7
Source File: EntityNBTPacket.java From NBTEdit with GNU General Public License v3.0 | 5 votes |
@Override public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) throws IOException { ByteBufInputStream bis = new ByteBufInputStream(buffer); DataInputStream nbt = new DataInputStream(bis); entityID = bis.readInt(); tag = NBTHelper.nbtRead(nbt); }
Example 8
Source File: TileNBTPacket.java From NBTEdit with GNU General Public License v3.0 | 5 votes |
@Override public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) throws IOException { ByteBufInputStream bis = new ByteBufInputStream(buffer); DataInputStream nbt = new DataInputStream(bis); x = bis.readInt(); y = bis.readInt(); z = bis.readInt(); tag = NBTHelper.nbtRead(nbt); }