Exemplo n.º 1
1
<?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';
ini_set('display_errors', 1);
//$client = new Client(new Version1X('http://localhost:1337'));
$userId = 6;
$client = new Client(new Version1X('https://chat.vdomax.com:1314'));
$client->initialize();
$client->emit('Authenticate', ['userId' => $userId]);
// $client->on('Authenticate:Success', function($msg){
// 	print_r($msg);
// });
//$client->emit('broadcast', ['foo' => 'bar']);
$client->emit('notify', $_GET);
$client->close();
Exemplo n.º 2
0
 public function sendToken($token)
 {
     $client = new Client(new Version1X('http://localhost:8888'));
     $client->initialize();
     $client->emit('activeToken', ['tokenKey' => $token]);
     $client->close();
 }
Exemplo n.º 3
0
 public function do_emit_message($message)
 {
     if (!$this->socket) {
         $this->do_create_socket();
     }
     $this->socket->emit('message', json_encode(['message' => $message, 'clientID' => $_REQUEST['data-socket']]));
 }
Exemplo n.º 4
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();
 }
Exemplo n.º 5
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;
     }
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
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');
 }
Exemplo n.º 8
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();
Exemplo n.º 9
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, ElephantIO\Engine\SocketIO\Version0X;
require __DIR__ . '/../../../../vendor/autoload.php';
$client = new Client(new Version0X('http://localhost:1337'));
$client->initialize();
$client->of('/namespace');
$client->emit('broadcast', ['foo' => 'bar']);
$client->close();
Exemplo n.º 10
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\Version0X;
require __DIR__ . '/../../../../vendor/autoload.php';
$client = new Client(new Version0X('http://localhost:1337'));
$client->initialize();
$client->emit('action', ['foo' => 'bar']);
$client->close();
Exemplo n.º 11
0
                $stmt->bindParam(':removeRoomName', $roomName);
                $stmt->execute();
            }
        }
    }
}
if (isset($_POST['refresh'])) {
    header("Refresh:0");
}
if (isset($_POST['join_server'])) {
    $ip = $_POST['servers'];
    setcookie('server_cookie', $ip, time() + 86400 * 30, '/');
    $username = $_COOKIE["user_cookie"];
    // If the selected server IS a turing server, use ElephantIO to pass the username and chip amount
    if (strpos($ip, 'http://192.168.1.101:') !== FALSE) {
        $client = new Client(new Version1X($ip));
        // This does not like it if you include the backslash at the end of the address!
        $sql = 'SELECT chipamount FROM users WHERE username = :username';
        $stmt = $db->prepare($sql);
        $stmt->bindParam(':username', $username);
        $stmt->execute();
        $chipAmount = $stmt->fetchColumn();
        $client->initialize();
        $client->emit('linkUsername', [$username, $chipAmount]);
        $client->emit('linkChipAmount', [$chipAmount]);
        $client->emit('disconnectLink', []);
        $client->close();
    }
    ?>
  <script>
    window.open("<?php 
Exemplo n.º 12
0
$port = 1337;
##############################
$problems = json_decode(file_get_contents(dirname(__FILE__) . "/problems/problems.json"), true);
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, 0, $port) or die('Could not bind to address');
socket_listen($sock);
while (true) {
    $client = socket_accept($sock);
    $input = socket_read($client, 1024000);
    extract((array) json_decode($input));
    $file_input_title = $problems[$problem_number]["file_title"];
    $problem_timeout = $problems[$problem_number]["info"]["timeout"];
    $file_input_data = $problems[$problem_number]["info"]["input"] === "null" ? "" : file_get_contents(dirname(__FILE__) . '/problems/' . strtolower($file_input_title) . '/' . $file_input_title . '.in', FILE_USE_INCLUDE_PATH);
    $file_output_data = file_get_contents(dirname(__FILE__) . '/problems/' . strtolower($file_input_title) . '/' . $file_input_title . '.out', FILE_USE_INCLUDE_PATH);
    compileProgram("/tmp/{$processname}/{$class}.java", "/tmp/{$processname}/", "/tmp/{$processname}/{$class}.class", $class, $inputs, $args, $processname, $data, $problem_number, $file_input_title, $file_input_data, $file_output_data, $problem_timeout, $team);
    $elephant = new ElephantIOClient('http://localhost:8008', 'socket.io', 1, false, true, true);
    $elephant->init();
    $elephant->send(ElephantIOClient::TYPE_EVENT, null, null, json_encode(array('name' => 'get_subs', 'args' => $team)));
    $elephant->send(ElephantIOClient::TYPE_EVENT, null, null, json_encode(array('name' => 'recalculate', 'args' => $team)));
    $elephant->close();
    socket_close($client);
}
// Close the master sockets
socket_close($sock);
function proc_timeout($start, $problem_timeout)
{
    //check if program has timed out
    return microtime(true) - $start > $problem_timeout ? true : false;
}
function proc_exec($cmd, $inputs, $type, $problem_timeout)
{
Exemplo n.º 13
0
<?php

require __DIR__ . '/../lib/ElephantIO/Client.php';
use ElephantIO\Client as ElephantIOClient;
$elephant = new ElephantIOClient('http://localhost:8000', 'socket.io', 1, false, true, true);
$elephant->init();
$elephant->send(ElephantIOClient::TYPE_EVENT, null, null, json_encode(array('name' => 'action', 'args' => 'foo')));
$elephant->close();
echo 'tryin to send `foo` to the event called action';
Exemplo n.º 14
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();
while (true) {
    $r = $client->read();
    if (!empty($r)) {
        var_dump($r);
    }
}
$client->close();
Exemplo n.º 15
0
<?php

require __DIR__ . '/../lib/ElephantIO/Client.php';
use ElephantIO\Client as ElephantIOClient;
$elephant = new ElephantIOClient('http://localhost:8000', 'socket.io', 1, false, true, true);
$elephant->init();
$elephant->emit('action', 'foo');
$elephant->close();
echo 'tryin to send `foo` to the event called action';