コード例 #1
0
ファイル: sendToken.php プロジェクト: baothaklien/Project3
 public function sendToken($token)
 {
     $client = new Client(new Version1X('http://localhost:8888'));
     $client->initialize();
     $client->emit('activeToken', ['tokenKey' => $token]);
     $client->close();
 }
コード例 #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();
 }
コード例 #3
0
ファイル: client.php プロジェクト: jucebox/cloudapi-lib-php
 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;
     }
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 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');
 }
コード例 #6
0
ファイル: client.php プロジェクト: timenz/elephant.io
<?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();