public static function sendLog($message)
 {
     return;
     if ($_SERVER["SERVER_NAME"] != "localhost") {
     }
     Yii::import('ext.ElephantIO.Client');
     if (!is_string($message)) {
         $message = NodeLogger::renderJSON($message);
     }
     //$elephant = new Client('http://pukul.in:10001', 'socket.io', 1, false, true, true);
     $elephant = new Client('http://localhost:8000', 'socket.io', 1, false, true, true);
     $elephant->init();
     $elephant->emit('newmessage', date("Y-m-d H:i:s") . "\n" . $message);
     $elephant->close();
     //echo "SEND MESSAGE ".$message;
 }
 /**
  * Processing loop
  */
 public function pump()
 {
     try {
         while ($this->isOpen()) {
             (yield $this->next());
         }
     } catch (\Exception $e) {
         if ($this->outputHeartbeatCoroutine) {
             $this->outputHeartbeatCoroutine->cancel();
             $this->outputHeartbeatCoroutine = null;
         }
         if ($this->inputHeartbeatCoroutine) {
             $this->inputHeartbeatCoroutine->cancel();
             $this->inputHeartbeatCoroutine = null;
         }
         (yield $this->client->close());
     }
 }
Example #3
0
 public function testCookieJar()
 {
     $cookieJar = dirname(__DIR__) . '/data/cookie-jar.txt';
     if (file_exists($cookieJar)) {
         unlink($cookieJar);
     }
     $client = new Client($this->testUrl);
     $client->setCookieJar($cookieJar);
     $client->get();
     $client->close();
     $this->assertTrue(file_exists($cookieJar));
     $this->assertTrue(!(strpos(file_get_contents($cookieJar), "\t" . 'server-cookie' . "\t" . 'contentOfServerCookie') === false));
 }