Example #1
0
 public function sendToken($token)
 {
     $client = new Client(new Version1X('http://localhost:8888'));
     $client->initialize();
     $client->emit('activeToken', ['tokenKey' => $token]);
     $client->close();
 }
Example #2
0
 public function send($event, array $message, $namespace = null)
 {
     $client = new Client(new IO($this->get_url));
     $client->initialize();
     if ($namespace) {
         $client->of($namespace);
     }
     $client->emit($event, $message);
     $client->close();
 }
Example #3
0
 public static function connect($accessToken, $clientId)
 {
     try {
         $client = new Client(new Version1X('https://cloudapi-01.nomos-system.com:443?' . http_build_query(array('access_token' => $accessToken, 'client' => $clientId)), '/control', array('version' => 3)));
         $client->initialize();
         return $client;
     } catch (Exception $e) {
         return false;
     }
 }
 public static function emit($node, $message)
 {
     try {
         $url = config('emitter.host') . ':' . config('emitter.port');
         $client = new Client(new Version1X($url));
         $client->initialize();
         $client->emit($node, $message);
         $client->close();
     } catch (ServerConnectionFailureException $ex) {
         //\Log::alert('failed to connect socket io stream on '.$url);
         return false;
     }
     return true;
 }
 public function sendMsg()
 {
     $room = request()->input('room');
     $msg = request()->input('msg');
     $url = url('/') . ":8080";
     $client = new Client(new Version1X($url));
     $client->initialize();
     if (trim($room) == '') {
         $client->emit('msgChatAllFromPHP', [$msg]);
     } else {
         $data = json_encode(['room' => $room, 'msg' => $msg]);
         $client->emit('msgChatGameFromPHP', [$data]);
     }
     $client->close();
     return redirect('integration_elephant_io');
 }
Example #6
0
<?php

/**
 * This file is part of the Elephant.io package
 *
 * For the full copyright and license information, please view the LICENSE file
 * that was distributed with this source code.
 *
 * @copyright Wisembly
 * @license   http://www.opensource.org/licenses/MIT-License MIT License
 */
use ElephantIO\Client;
use ElephantIO\Engine\SocketIO\Version1X;
require __DIR__ . '/../../../../vendor/autoload.php';
$client = new Client(new Version1X('http://localhost:1337'));
$client->initialize();
$client->emit('broadcast', ['foo' => 'bar']);
$client->close();