@Override public byte[] encode() { final byte[] name = StringUtils.toUTF8(this.m_inviterName); final byte[] groupName = StringUtils.toUTF8(this.m_groupName); final int sizeDatas = 3 + name.length + 1 + groupName.length + 8; final ByteBuffer buffer = ByteBuffer.allocate(sizeDatas); buffer.put(this.m_groupType); buffer.put((byte) (this.m_invitationAccepted ? 1 : 0)); buffer.put((byte) name.length); buffer.put(name); buffer.put((byte) groupName.length); buffer.put(groupName); buffer.putLong(this.m_inviterId); if (this.m_sendToGlobalServer) { return this.addClientHeader((byte) 6, buffer.array()); } return this.addClientHeader((byte) 2, buffer.array()); }
@Override public boolean decode(final byte[] rawDatas) { final ByteBuffer bb = ByteBuffer.wrap(rawDatas); this.m_eventId = bb.getLong(); this.m_invitedId = bb.getLong(); final byte[] tInvitedName = new byte[bb.get()]; bb.get(tInvitedName); this.m_invitedName = StringUtils.fromUTF8(tInvitedName); this.m_result = bb.get(); return true; }
public final byte[] serialize() { final byte[] cdata = StringUtils.toUTF8(this.m_criterion); final int presize = cdata.length; final ByteBuffer bb = ByteBuffer.allocate(32 + presize); bb.putInt(this.m_id); bb.put(this.m_order); bb.putInt(this.m_gfx); bb.putInt(cdata.length); bb.put(cdata); bb.put((byte) (this.m_success ? 1 : 0)); bb.putInt(this.m_itemId); bb.putShort(this.m_itemQty); bb.putInt(this.m_xp); bb.putInt(this.m_kama); bb.putInt(this.m_guildPoints); return bb.array(); }