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();
 }
 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 #5
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();
Example #6
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)
{
    $output = "";
    $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
    $process = proc_open($cmd, $descriptorspec, $pipes, NULL, $_ENV);
    $starttime = microtime(true);