public function parse($data)
    {
        $frames = array();

        while ($data != '') {
            $data = $this->currentFrame->parse($data);
            if ($data != '') {
                $frames[] = $this->currentFrame;
                $this->currentFrame = new Net_Notifier_WebSocket_Frame();
            }
        }

        // if we received exactly enough data, the last frame is also complete
        $state = $this->currentFrame->getState();
        if ($state === Net_Notifier_WebSocket_Frame::STATE_DONE) {
            $frames[] = $this->currentFrame;
            $this->currentFrame = new Net_Notifier_WebSocket_Frame();
        }

        return $frames;
    }