Example usage for io.netty.buffer ByteBuf readInt

List of usage examples for io.netty.buffer ByteBuf readInt

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf readInt.

Prototype

public abstract int readInt();

Source Link

Document

Gets a 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.

Usage

From source file:com.mrcrayfish.furniture.network.message.MessageMineBayBrowse.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    this.itemNum = buf.readInt();
    this.x = buf.readInt();
    this.y = buf.readInt();
    this.z = buf.readInt();
}

From source file:com.mrcrayfish.furniture.network.message.MessageMineBayBuy.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    this.itemNum = buf.readInt();
    this.x = buf.readInt();
    this.y = buf.readInt();
    this.z = buf.readInt();
    this.shouldClear = buf.readBoolean();
}

From source file:com.mrcrayfish.furniture.network.message.MessagePresent.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    this.present = ByteBufUtils.readItemStack(buf);
    this.x = buf.readInt();
    this.y = buf.readInt();
    this.z = buf.readInt();
}

From source file:com.mrcrayfish.furniture.network.message.MessageTVClient.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    this.channel = buf.readInt();
    this.x = buf.readInt();
    this.y = buf.readInt();
    this.z = buf.readInt();
}

From source file:com.mrgreaper.twisted.handlers.TwistedPacket.java

License:MIT License

public void readBytes(ByteBuf bytes) {
    i = bytes.readInt();

    System.out.println("Recieved packet with the int i = " + i);
}

From source file:com.nanxiaoqiang.test.netty.protocol.demo1.codec.MarshallingDecoder.java

License:Apache License

protected Object decode(ByteBuf in) throws Exception {
    int objectSize = in.readInt();// intdata
    ByteBuf buf = in.slice(in.readerIndex(), objectSize);// ?Data size??
    ByteInput input = new ChannelBufferByteInput(buf);
    try {/*from  w w w.  j  a  v  a  2  s. co  m*/
        unmarshaller.start(input);
        Object obj = unmarshaller.readObject();// marshallingObject
        unmarshaller.finish();
        in.readerIndex(in.readerIndex() + objectSize);// 
        return obj;
    } finally {
        unmarshaller.close();
    }
}

From source file:com.nanxiaoqiang.test.netty.protocol.demo1.codec.NettyMessageDecoder.java

License:Apache License

@Override
protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
    ByteBuf frame = (ByteBuf) super.decode(ctx, in);
    if (frame == null) {
        return null;// ?
    }// w  ww.ja v  a2  s.  c om

    NettyMessage message = new NettyMessage();
    Header header = new Header();
    header.setCrcCode(frame.readInt());
    header.setLength(frame.readInt());
    header.setSessionID(frame.readLong());
    header.setType(frame.readByte());
    header.setPriority(frame.readByte());

    int size = frame.readInt();// ?Header?
    if (size > 0) {
        Map<String, Object> attch = new HashMap<String, Object>(size);
        int keySize = 0;
        byte[] keyArray = null;
        String key = null;
        for (int i = 0; i < size; i++) {
            keySize = frame.readInt();
            keyArray = new byte[keySize];
            frame.readBytes(keyArray);
            key = new String(keyArray, "UTF-8");// keyUTF-8String
            attch.put(key, marshallingDecoder.decode(frame));
        }
        keyArray = null;
        key = null;
        header.setAttachment(attch);
    }
    // Header End
    if (frame.readableBytes() > 4) {
        message.setBody(marshallingDecoder.decode(frame));// 4Data
    }
    message.setHeader(header);
    return message;
}

From source file:com.newlandframework.avatarmq.netty.MessageObjectDecoder.java

License:Apache License

protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
    if (in.readableBytes() < MessageObjectDecoder.MESSAGE_LENGTH) {
        return;/*from  w w w .  ja  v  a2  s  . co  m*/
    }

    in.markReaderIndex();
    int messageLength = in.readInt();

    if (messageLength < 0) {
        ctx.close();
    }

    if (in.readableBytes() < messageLength) {
        in.resetReaderIndex();
        return;
    } else {
        byte[] messageBody = new byte[messageLength];
        in.readBytes(messageBody);

        try {
            Object obj = util.decode(messageBody);
            out.add(obj);
        } catch (IOException ex) {
            Logger.getLogger(MessageObjectDecoder.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.newlandframework.rpc.serialize.MessageDecoder.java

License:Apache License

protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
    if (in.readableBytes() < MessageDecoder.MESSAGE_LENGTH) {
        return;//ww w .  ja  v a  2 s .  c o  m
    }

    in.markReaderIndex();
    int messageLength = in.readInt();

    if (messageLength < 0) {
        ctx.close();
    }

    if (in.readableBytes() < messageLength) {
        in.resetReaderIndex();
        return;
    } else {
        byte[] messageBody = new byte[messageLength];
        in.readBytes(messageBody);

        try {
            Object obj = util.decode(messageBody);
            out.add(obj);
        } catch (IOException ex) {
            Logger.getLogger(MessageDecoder.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.noahkurrack.onenine.network.MessageSingleParticleEvent.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {

    int particleNameLength = buf.readInt();
    this.particleName = new String(buf.readBytes(particleNameLength).array());
    this.xCoord = buf.readDouble();
    this.yCoord = buf.readDouble();
    this.zCoord = buf.readDouble();
    this.xVelocity = buf.readDouble();
    this.yVelocity = buf.readDouble();
    this.zVelocity = buf.readDouble();

}