private function createFrame($hex = NULL) { $frame = new Frame(TRUE); if (isset($hex)) { $frame->gotData(hex2bin($hex)); } return $frame; }
/** * Called when some data has been received from the client. * * @param string $data The data received. */ public function gotData($data) { if ($this->currentFrame === null) { $this->currentFrame = new Frame(true); } try { $this->currentFrame->gotData($data); } catch (BadFrameException $ex) { $this->closeConnection(); } if (!$this->currentFrame->isComplete()) { // The full frame hasn't been received. return; } $this->gotFrame($this->currentFrame); $extra = $this->currentFrame->getExtraData(); $this->currentFrame = null; if ($extra !== null) { $this->gotData($extra); } }