Exemplo n.º 1
0
<?php

require 'ElephantIOClient.class.php';
$elephant = new ElephantIOClient('http://127.0.0.1:8080');
$elephant->init();
$elephant->send(ElephantIOClient::TYPE_MESSAGE, null, null, 'Hello World!');
$elephant->keepAlive();
Exemplo n.º 2
0
 /**
  * 等待通讯
  */
 public function wait()
 {
     $this->_client->keepAlive();
 }
Exemplo n.º 3
0
 /**
  * 等待通讯
  */
 public function wait()
 {
     while (true) {
         if ($this->_client) {
             $this->_client->keepAlive();
         }
         if ($this->_autoReconnect === false) {
             break;
         } else {
             if ($this->_client) {
                 $this->_client->close();
                 $this->_client = null;
             }
             $this->_messageCallbacks = array();
             try {
                 $this->_client = new ElephantIOClient("http://" . $this->_server . ":" . $this->_port, "socket.io", 1, false, true, $this->_debug);
                 $this->init();
                 if ($this->_useSessionId) {
                     $this->connect_v2();
                 } else {
                     $this->connect();
                 }
             } catch (Exception $e) {
                 if ($this->_client) {
                     $this->_client->close();
                     $this->_client = null;
                 }
                 sleep(5);
             }
         }
     }
 }