Beispiel #1
0
 static function socketEvent($event, array $data)
 {
     $options = array('context' => array('http' => array('header' => 'Cookie: access=' . urlencode(WS_SERVER_KEY))));
     if (preg_match(new RegExp('\\.lc$'), WS_SERVER_DOMAIN)) {
         $options['context']['ssl'] = array("verify_peer" => false, "verify_peer_name" => false);
     }
     $elephant = new \ElephantIO\Client(new SocketIOEngineVersion1X('https://ws.' . WS_SERVER_DOMAIN . ':8667', $options));
     $elephant->initialize();
     $elephant->emit($event, $data);
     $elephant->close();
 }
Beispiel #2
0
<?php

require_once "elephant.io/autoload.php";
//$elephant = new ElephantIO\Client('http://121.40.19.35:333', 'socket.io', 1, false, true, true);
$elephant = new ElephantIO\Client(new ElephantIO\Engine\SocketIO\Version1X('http://localhost:333'));
$elephant->initialize();
$elephant->emit('broadcast', ["aaa", "bbb"]);
$elephant->close();
echo 'tryin to send `bar` to the event {"aaa":"bbb"}';
?>


 function sendServer($channel, $data)
 {
     $ELEPHANTIO_PATH = $this->Module->getPath() . '/classes/elephant.io/src';
     require_once $ELEPHANTIO_PATH . '/Client.php';
     require_once $ELEPHANTIO_PATH . '/AbstractPayload.php';
     require_once $ELEPHANTIO_PATH . '/EngineInterface.php';
     require_once $ELEPHANTIO_PATH . '/Engine/AbstractSocketIO.php';
     require_once $ELEPHANTIO_PATH . '/Engine/SocketIO/Session.php';
     require_once $ELEPHANTIO_PATH . '/Engine/SocketIO/Version1X.php';
     require_once $ELEPHANTIO_PATH . '/Exception/MalformedUrlException.php';
     require_once $ELEPHANTIO_PATH . '/Exception/ServerConnectionFailureException.php';
     require_once $ELEPHANTIO_PATH . '/Exception/SocketException.php';
     require_once $ELEPHANTIO_PATH . '/Exception/UnsupportedActionException.php';
     require_once $ELEPHANTIO_PATH . '/Exception/UnsupportedTransportException.php';
     require_once $ELEPHANTIO_PATH . '/Payload/Decoder.php';
     require_once $ELEPHANTIO_PATH . '/Payload/Encoder.php';
     $EIO = new ElephantIO\Client(new ElephantIO\Engine\SocketIO\Version1X('http://127.0.0.1:3000', ['timeout' => 5]));
     $EIO->initialize();
     $EIO->emit('push', array($channel, $data));
     $EIO->close();
 }