protected void handleData(ReadableByteChannel channel) throws IOException {
        SSLEngineResult result;
        
        if (this.initialHSComplete) {
            throw new IllegalStateException();
        }
        
        //int pos = this.requestBB.position();
        
        if (channel.read(this.inNetBB) == -1) {
            this.sslEngine.closeInbound();
            return;
        }
        
        do {
            this.resizeRequestBB();
            this.inNetBB.flip();
            result = this.sslEngine.unwrap(this.inNetBB, this.requestBB);
            this.inNetBB.compact();
            
            switch (result.getStatus()) {
            case BUFFER_OVERFLOW:
                this.appBBSize = this.sslEngine.getSession().getApplicationBufferSize();
                break;
            case BUFFER_UNDERFLOW:
                this.netBBSize = this.sslEngine.getSession().getPacketBufferSize();
                if (this.netBBSize > this.inNetBB.capacity()) {
                    this.resizeResponseBB();
                    break;
                }
            case OK:
                if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
                    // TODO doTasks();
                }
                break;
            default:
                throw new IOException("SSLEngine error during data read: " + result.getStatus());
            }
        } while ((this.inNetBB.position() != 0) && result.getStatus() != Status.BUFFER_UNDERFLOW);
        
        this.emit("data", new DataEvent(this.requestBB));
        
        //return (this.requestBB.position() - pos);
    }