Example #1
0
 /**
  * Connect to server.
  *
  * @param integer $timeout Number of seconds until the connect() system call should timeout.
  *
  * @throws \Exception Exception raised if connection fails.
  * @return void
  */
 public function connect($timeout = null)
 {
     $this->streamSocket = $this->getStream($this->options->getAddress(), $timeout);
     $msg = 'CONNECT ' . $this->options;
     $this->send($msg);
     $response = $this->receive();
     $this->ping();
     $response = $this->receive();
     if ($response !== "PONG") {
         if (strpos($response, '-ERR') !== false) {
             throw new \Exception("Failing connection: {$response}");
         }
     }
 }
Example #2
0
 /**
  * Connect to server.
  *
  * @return void
  */
 public function connect()
 {
     $this->streamSocket = $this->getStream($this->options->getAddress());
     $msg = 'CONNECT ' . $this->options->toJSON();
     $this->send($msg);
 }
 public function testGetterAndSetter()
 {
     $configuration = ['host' => 'test-host', 'port' => 1234, 'username' => 'test-username', 'password' => 'test-password', 'vhost' => 'test-vhost', 'read_timeout' => 12, 'write_timeout' => 13, 'connect_timeout' => 432, 'heartbeat' => 234, 'channel_max' => 16, 'frame_max' => 16, 'persistent' => true];
     $options = new ConnectionOptions();
     $options->setFromArray($configuration);
     static::assertEquals($configuration['host'], $options->getHost());
     static::assertEquals($configuration['port'], $options->getPort());
     static::assertEquals($configuration['username'], $options->getUsername());
     static::assertEquals($configuration['password'], $options->getPassword());
     static::assertEquals($configuration['vhost'], $options->getVhost());
     static::assertEquals($configuration['read_timeout'], $options->getReadTimeout());
     static::assertEquals($configuration['write_timeout'], $options->getWriteTimeout());
     static::assertEquals($configuration['heartbeat'], $options->getHeartbeat());
     static::assertEquals($configuration['connect_timeout'], $options->getConnectTimeout());
     static::assertEquals($configuration['channel_max'], $options->getChannelMax());
     static::assertEquals($configuration['frame_max'], $options->getFrameMax());
     static::assertEquals($configuration['persistent'], $options->isPersistent());
 }
Example #4
0
 /**
  * Connect to server.
  *
  * @param integer $timeout Number of seconds until the connect() system call should timeout.
  * @throws \Exception Exception raised if connection fails.
  * @return void
  */
 public function connect($timeout = null)
 {
     $this->streamSocket = $this->getStream($this->options->getAddress(), $timeout);
     $msg = 'CONNECT ' . $this->options;
     $this->send($msg);
 }