Code example for ByteBuffer

Methods: flip, position, putShort, slice

0
	 * @param con 
	 * @param buf 
	 */ 
	public final void write(AionConnection con, ByteBuffer buf)
	{ 
		buf.putShort((short) 0);
		writeImpl(con, buf);
		buf.flip();
		buf.putShort((short) 0);
		ByteBuffer b = buf.slice();
 
		short size = (short) (con.encrypt(b) + 2);
		buf.putShort(0, size);
		buf.position(0).limit(size);
	} 
	 
	/** 
	 * Write data that this packet represents to given byte buffer. 
	 *  
	 * @param con 
	 * @param buf