Java Code Examples for io.netty.buffer.ByteBuf#getIntLE()

The following examples show how to use io.netty.buffer.ByteBuf#getIntLE() . 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: MysqlServerHandler.java    From antsdb with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void run(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
    int readerIndex = buf.readerIndex() - 4; 
    buf.readerIndex(readerIndex);
    int size = buf.getIntLE(readerIndex) & 0xffffff;
    ByteBuffer niobuf = buf.nioBuffer(readerIndex, size + 4);
    niobuf.order(ByteOrder.LITTLE_ENDIAN);
    buf.readerIndex(readerIndex + size + 4);
    int result = this.mysession.run(niobuf);
    if (result == 1) {
        return;
    }
    else if (result == -1) {
        switchToSSL();
        return;
    }
    else if (result == -2) {
        ctx.close();
        return;
    }
    else {
        throw new IllegalArgumentException();
    }
}
 
Example 2
Source File: PacketDecoder.java    From antsdb with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    // do we have length field in buffer ?
    
    if (!in.isReadable(4)) {
        return;
    }

    // do we have entire packet in the buffer?
    
    int readerIndex = in.readerIndex(); 
    int size = in.getIntLE(readerIndex) & 0xffffff;
    if (in.readableBytes() < size + 4) {
        return;
    }
    
    // continue 
    
    in.readInt();
    out.add(in);
}
 
Example 3
Source File: ConvChannelManager.java    From java-Kcp with Apache License 2.0 4 votes vote down vote up
private int getConv(DatagramPacket msg) {
    ByteBuf byteBuf = msg.content();
    return byteBuf.getIntLE(byteBuf.readerIndex() + convIndex);
}