Example #1
0
 /**
  * @param string $payload
  *
  * @return string
  * @throws ConnectionException
  */
 public function send($payload)
 {
     if (!$this->ws->isConnected()) {
         throw new ConnectionException(sprintf('Could not connect to "%s"', $this->address));
     }
     $this->ws->send($payload);
     $response = $this->ws->receive();
     if (($opCode = $this->ws->getLastOpcode()) !== 'text') {
         throw new ConnectionException(sprintf('Received non-text frame of type "%s" with text: "%s"', $opCode, $response));
     }
     return $response;
 }