/** * Open the transport for reading/writing * * @throws TTransportException if cannot open */ public function open() { if (!$this->transport_->isOpen()) { $this->transport_->open(); } try { $auth = '' . chr(0) . $this->username_ . chr(0) . $this->password_; $this->saslWrite_(self::METHOD, self::START); $this->saslWrite_($auth, self::COMPLETE); $saslFrame = $this->saslRead_(true); $this->saslComplete_ = self::COMPLETE == $saslFrame['status']; if (!$this->saslComplete_) { throw new TTransportException('Could not perform SASL auth.'); } } catch (TTransportException $e) { throw $e; } catch (Exception $e) { throw new TTransportException('SASL Auth failed: ', $e->getMessage()); } return true; }
public function isOpen() { return $this->transport_->isOpen(); }