List of usage examples for io.netty.buffer ByteBuf readInt
public abstract int readInt();
From source file:com.mpush.api.protocol.Packet.java
License:Apache License
public static Packet decodePacket(Packet packet, ByteBuf in, int bodyLength) { packet.cc = in.readShort();//read cc packet.flags = in.readByte();//read flags packet.sessionId = in.readInt();//read sessionId packet.lrc = in.readByte();//read lrc //read body//w w w . j a va 2 s. c om if (bodyLength > 0) { in.readBytes(packet.body = new byte[bodyLength]); } return packet; }
From source file:com.mpush.common.message.ByteBufMessage.java
License:Apache License
public byte[] decodeBytes(ByteBuf body) { int fieldLength = body.readShort(); if (fieldLength == 0) return null; if (fieldLength == Short.MAX_VALUE) { fieldLength += body.readInt(); }/*from w w w .j a v a 2 s.c o m*/ byte[] bytes = new byte[fieldLength]; body.readBytes(bytes); return bytes; }
From source file:com.mpush.common.message.ByteBufMessage.java
License:Apache License
public int decodeInt(ByteBuf body) { return body.readInt(); }
From source file:com.mpush.netty.codec.PacketDecoder.java
License:Apache License
private Packet decodeFrame(ByteBuf in) { int readableBytes = in.readableBytes(); int bodyLength = in.readInt(); if (readableBytes < (bodyLength + Packet.HEADER_LEN)) { return null; }/*from www . j a v a 2s . com*/ if (bodyLength > maxPacketSize) { throw new TooLongFrameException("packet body length over limit:" + bodyLength); } return decodePacket(new Packet(in.readByte()), in, bodyLength); }
From source file:com.mpush.netty.codec.PacketDecoder.java
License:Apache License
public static Packet decodeFrame(DatagramPacket frame) { ByteBuf in = frame.content(); int readableBytes = in.readableBytes(); int bodyLength = in.readInt(); if (readableBytes < (bodyLength + Packet.HEADER_LEN)) { return null; }// w ww . jav a2s . co m return decodePacket(new UDPPacket(in.readByte(), frame.sender()), in, bodyLength); }
From source file:com.mrcrayfish.furniture.network.message.MessageConfig.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { int length = buf.readInt(); int count = 0; while (count != length) { String data = ByteBufUtils.readUTF8String(buf); itemData.add(data);// w ww . ja v a2 s . c om count++; } }
From source file:com.mrcrayfish.furniture.network.message.MessageDishwasher.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { this.type = buf.readInt(); this.x = buf.readInt(); this.y = buf.readInt(); this.z = buf.readInt(); }
From source file:com.mrcrayfish.furniture.network.message.MessageEmptyBin.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { this.x = buf.readInt(); this.y = buf.readInt(); this.z = buf.readInt(); }
From source file:com.mrcrayfish.furniture.network.message.MessageFillBasin.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { this.hasWater = buf.readBoolean(); this.x = buf.readInt(); this.y = buf.readInt(); this.z = buf.readInt(); }
From source file:com.mrcrayfish.furniture.network.message.MessageFillBath.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { this.waterLevel = buf.readInt(); this.bathOneX = buf.readInt(); this.bathOneY = buf.readInt(); this.bathOneZ = buf.readInt(); this.bathTwoX = buf.readInt(); this.bathTwoY = buf.readInt(); this.bathTwoZ = buf.readInt(); }