private boolean handleMessage(SelectionKey key, SocketChannel socketChannel, ProtocolHeader protocolHeader) {
        long numRead;
        numRead = 0;

        int offset = 1;
        buffer[offset] = ByteBuffer.allocate(ProtocolUtils.getBodySize(protocolHeader));
        numRead = readBuffer(key, offset);

        if (socketChannel.isOpen()) {

            byteReceived.inc(numRead);

            try {
                buffer[1].flip();

                switch (protocolHeader.getCommandType()) {
                    case Protocol.HEADER_COMMAND_PUBLISH: {
                        onPublish(buffer[1],key);
                        break;
                    }
                    case Protocol.HEADER_COMMAND_SUBSCRIBE: {
                        onRegisterSubscribe(buffer[1], key);
                        break;
                    }
                }

            } catch (Exception ex) {
                log.severe("Error on read, cause: " + ex.getMessage());
            }
            return true;
        }

        return false;
    }