Java Code Examples for io.netty.buffer.ByteBuf.readIntLE()

The following are Jave code examples for showing how to use readIntLE() of the io.netty.buffer.ByteBuf class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ProtocolSupportPocketStuff   File: ClientLoginPacket.java   Source Code and License Vote up 6 votes
@SuppressWarnings("resource")
@Override
public void readFromClientData(Connection connection, ByteBuf clientData) {
	protocolVersion = clientData.readInt(); //protocol version

	ByteBuf logindata = Unpooled.wrappedBuffer(ArraySerializer.readByteArray(clientData, connection.getVersion()));

	// skip chain data
	logindata.skipBytes(logindata.readIntLE());

	// decode skin data
	try {
		InputStream inputStream = new ByteBufInputStream(logindata, logindata.readIntLE());
		ByteArrayOutputStream result = new ByteArrayOutputStream();
		byte[] buffer = new byte[1024];
		int length;
		while ((length = inputStream.read(buffer)) != -1) {
			result.write(buffer, 0, length);
		}
		clientPayload = decodeToken(result.toString("UTF-8"));
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example 2
Project: JRediClients   File: JCacheEventCodec.java   Source Code and License Vote up 5 votes
@Override
    public Object decode(ByteBuf buf, State state) throws IOException {
        List<Object> result = new ArrayList<Object>();
        int keyLen;
        if (PlatformDependent.isWindows()) {
keyLen = buf.readIntLE();
        } else {
keyLen = (int) buf.readLongLE();
        }
        ByteBuf keyBuf = buf.readSlice(keyLen);
        Object key = codec.getMapKeyDecoder().decode(keyBuf, state);
        result.add(key);

        int valueLen;
        if (PlatformDependent.isWindows()) {
valueLen = buf.readIntLE();
        } else {
valueLen = (int) buf.readLongLE();
        }
        ByteBuf valueBuf = buf.readSlice(valueLen);
        Object value = codec.getMapValueDecoder().decode(valueBuf, state);
        result.add(value);
        
        if (sync) {
            double syncId = buf.order(ByteOrder.LITTLE_ENDIAN).readDouble();
            result.add(syncId);
        }
        
        return result;
    }
 
Example 3
Project: JRediClients   File: MapCacheEventCodec.java   Source Code and License Vote up 5 votes
private Object decode(ByteBuf buf, State state, Decoder<?> decoder) throws IOException {
     int keyLen;
     if (PlatformDependent.isWindows()) {
keyLen = buf.readIntLE();
     } else {
keyLen = (int) buf.readLongLE();
     }
     ByteBuf keyBuf = buf.readSlice(keyLen);
     Object key = decoder.decode(keyBuf, state);
     return key;
 }
 
Example 4
Project: JungleTree   File: LoginCodec.java   Source Code and License Vote up 4 votes
private byte[] readSection(ByteBuf buf) {
    int length = buf.readIntLE();
    byte[] section = new byte[length];
    buf.readBytes(section);
    return section;
}