public function sendApiRequest($number, $content, $id)
 {
     $client = new Client(getSocketUrl());
     $client->setTimeout(10000);
     $client->send($this->buildApiRegisterRequest());
     $result = $client->receive();
     hist('api.response', $result, $id);
     $client->send($this->buildApiRequest($number, $content));
     $result = $client->receive();
     hist('api.response', $result, $id);
     hist('sms.send', 'Sent SMS to ' . $number . ': ' . $content, $id);
 }
 public function testChangeTimeout()
 {
     $timeout = 1;
     try {
         $ws = new Client('ws://example.org:1111', array('timeout' => 5));
         $ws->setTimeout($timeout);
         $start_time = microtime(true);
         $ws->send('foo');
     } catch (WebSocket\ConnectionException $e) {
         $this->assertLessThan($timeout + 0.2, microtime(true) - $start_time);
         $this->assertGreaterThan($timeout - 0.2, microtime(true) - $start_time);
     }
     if (!isset($e)) {
         $this->fail('Should have timed out and thrown a ConnectionException');
     }
 }
 /**
  * @return Client
  */
 protected function createClient()
 {
     $client = new Client($this->socketUrl);
     $client->setTimeout(86400 * 1000);
     return $client;
 }