@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; }