Exemplo n.º 1
0
 /**
  * Connects to the websocket
  *
  * @param boolean $keepAlive keep alive the connection (not supported yet) ?
  * @return $this
  */
 public function initialize($keepAlive = false)
 {
     try {
         $this->engine->connect();
         $this->isConnected = true;
         if (true === $keepAlive) {
             $this->engine->keepAlive();
         }
     } catch (SocketException $e) {
         $this->logger->error('Could not connect to the server', ['exception' => $e]);
         throw $e;
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Connects to the websocket
  *
  * @param boolean $keepAlive keep alive the connection (not supported yet) ?
  * @return $this
  */
 public function initialize($keepAlive = false)
 {
     try {
         null !== $this->logger && $this->logger->debug('Connecting to the websocket');
         $this->engine->connect();
         null !== $this->logger && $this->logger->debug('Connected to the server');
         if (true === $keepAlive) {
             null !== $this->logger && $this->logger->debug('Keeping alive the connection to the websocket');
             $this->engine->keepAlive();
         }
     } catch (SocketException $e) {
         null !== $this->logger && $this->logger->error('Could not connect to the server', ['exception' => $e]);
         throw $e;
     }
     return $this;
 }