@Override
	protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
		if(buffer.readable()) {
			int opcode = buffer.readUnsignedByte();
			int length = Constants.PACKET_LENGTHS[opcode];
			if (opcode < 0) {
				buffer.discardReadBytes();
				return null;
			}
			if (length == -1) {
				if(buffer.readable()) {
					length = buffer.readUnsignedByte();
				}
			}
			if(length <= buffer.readableBytes() && length > 0) {
				byte[] payload = new byte[length];
				buffer.readBytes(payload, 0, length);
				Message message = new Message(opcode, PacketType.STANDARD, ChannelBuffers.wrappedBuffer(payload));
				return message;
			}
		}
		return null;
	}