public void receiveMessage(ChannelBuffer message) {
        try {
            while(message.readable() && !throttled) { // 当writerIndex > readerIndex，并且不节流时，满足条件
                if (bb != null) { // 不为null
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("message readable " + message.readableBytes()
                                + " bb len " + bb.remaining() + " " + bb);
                        ByteBuffer dat = bb.duplicate();
                        dat.flip();
                        LOG.trace(Long.toHexString(sessionId)
                                + " bb 0x"
                                + ChannelBuffers.hexDump(
                                        ChannelBuffers.copiedBuffer(dat)));
                    }

                    if (bb.remaining() > message.readableBytes()) { // bb剩余空间大于message中可读字节大小
                        // 确定新的limit
                        int newLimit = bb.position() + message.readableBytes();
                        bb.limit(newLimit);
                    }
                    // 将message写入bb中
                    message.readBytes(bb);
                    // 重置bb的limit
                    bb.limit(bb.capacity());

                    if (LOG.isTraceEnabled()) {
                        LOG.trace("after readBytes message readable "
                                + message.readableBytes()
                                + " bb len " + bb.remaining() + " " + bb);
                        ByteBuffer dat = bb.duplicate();
                        dat.flip();
                        LOG.trace("after readbytes "
                                + Long.toHexString(sessionId)
                                + " bb 0x"
                                + ChannelBuffers.hexDump(
                                        ChannelBuffers.copiedBuffer(dat)));
                    }
                    if (bb.remaining() == 0) { // 已经读完message，表示内容已经全部接收
                        // 统计接收信息
                        packetReceived();
                        // 翻转，可读
                        bb.flip();

                        ZooKeeperServer zks = this.zkServer;
                        if (zks == null) { // Zookeeper服务器为空
                            throw new IOException("ZK down");
                        }
                        if (initialized) { // 未被初始化
                            // 处理bb中包含的包信息
                            zks.processPacket(this, bb);

                            if (zks.shouldThrottle(outstandingCount.incrementAndGet())) { // 是否已经节流
                                // 不接收数据
                                disableRecvNoWait();
                            }
                        } else { // 已经初始化
                            LOG.debug("got conn req request from "
                                    + getRemoteSocketAddress());
                            // 处理连接请求
                            zks.processConnectRequest(this, bb);
                            initialized = true;
                        }
                        bb = null;
                    }
                } else { // bb为null
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("message readable "
                                + message.readableBytes()
                                + " bblenrem " + bbLen.remaining());
                        // 复制bbLen缓冲
                        ByteBuffer dat = bbLen.duplicate();
                        // 翻转
                        dat.flip();
                        LOG.trace(Long.toHexString(sessionId)
                                + " bbLen 0x"
                                + ChannelBuffers.hexDump(
                                        ChannelBuffers.copiedBuffer(dat)));
                    }

                    if (message.readableBytes() < bbLen.remaining()) { // bb剩余空间大于message中可读字节大小
                        // 重设bbLen的limit
                        bbLen.limit(bbLen.position() + message.readableBytes());
                    }
                    // 将message内容写入bbLen中
                    message.readBytes(bbLen);
                    // 重置bbLen的limit
                    bbLen.limit(bbLen.capacity());
                    if (bbLen.remaining() == 0) { // 已经读完message，表示内容已经全部接收
                        // 翻转
                        bbLen.flip();

                        if (LOG.isTraceEnabled()) {
                            LOG.trace(Long.toHexString(sessionId)
                                    + " bbLen 0x"
                                    + ChannelBuffers.hexDump(
                                            ChannelBuffers.copiedBuffer(bbLen)));
                        }
                        // 读取position后四个字节
                        int len = bbLen.getInt();
                        if (LOG.isTraceEnabled()) {
                            LOG.trace(Long.toHexString(sessionId)
                                    + " bbLen len is " + len);
                        }
                        
                        // 清除缓存
                        bbLen.clear();
                        if (!initialized) { // 未被初始化
                            if (checkFourLetterWord(channel, message, len)) { // 是否是四个字母的命令
                                return;
                            }
                        }
                        if (len < 0 || len > BinaryInputArchive.maxBuffer) {
                            throw new IOException("Len error " + len);
                        }
                        // 根据len重新分配缓冲，以便接收内容
                        bb = ByteBuffer.allocate(len);
                    }
                }
            }
        } catch(IOException e) {
            LOG.warn("Closing connection to " + getRemoteSocketAddress(), e);
            close();
        }
    }
