Net/Notifier/WebSocket/FrameParser.php
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;
    }
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;
    }
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 ; }
Parses WebSocket frames out of a raw data stream

Any numbe of frames may be parsed. If the data chunk contains no
complete frames, no frames may be returned. The frame parses maintains
its state so subsequent data reads can be passed to this method to
complete partial frames.

@param string $data the raw data.

@return array an array of parsed {@link Net_Notifier_WebSocket_Frame}
objects.
Parses WebSocket frames out of a raw data stream