protected function _connect() { $connect_params = array('accept-version' => '1.0,1.1,1.2', 'heart-beat' => '0,0'); $accepted_headers = array('host', 'login', 'passcode'); foreach ($accepted_headers as $header) { if (isset($this->_connect_options[$header])) { $connect_params[$header] = $this->_connect_options[$header]; } } $connect_frame = new Frame(Frame::COMMAND_CONNECT, '', $connect_params); $this->_connection->write($connect_frame); if ($response = $this->_connection->readFrame()) { $this->_server_info = $response->getHeaders(); } else { throw new ConnectionException('No response from server.'); } }
/** * Read response frame from server * * @return Frame|false when no frame to read */ public function readFrame() { return array_shift($this->unprocessedFrames) ?: $this->connection->readFrame(); }
/** * @expectedException \Stomp\Exception\StompException */ public function testReadFrameThrowsExceptionIfNotConnected() { $connection = new Connection('tcp://localhost'); $connection->readFrame(); }