start() public method

Start the transport
public start ( boolean $startLoop = true )
$startLoop boolean
Ejemplo n.º 1
0
 /**
  * Start the transport
  *
  * @param boolean $startLoop
  * @throws \Exception
  */
 public function start($debug = false, $startLoop = true)
 {
     if (!$debug) {
         Logger::set(new NullLogger());
     }
     parent::start($startLoop);
 }
Ejemplo n.º 2
0
 /**
  *
  * @param \Thruway\ClientSession $session
  * @param \Thruway\Transport\TransportInterface $transport
  */
 public function onSessionStart($session, $transport)
 {
     $session->register('add_command', [$this, 'addCommand']);
     $session->register('status', [$this, 'status']);
     $session->register('start_process', [$this, 'startProcess']);
     $session->register('stop_process', [$this, 'stopProcess']);
     $session->register('restart_process', [$this, 'restartProcess']);
     $session->register('add_instance', [$this, 'addInstance']);
     //Congestion Manager Client.  This needs to be a separate client because it needs to listen on the main realm and not `process_manager`.
     $config = $this->container->getParameter('voryx_thruway');
     $congestionManager = new Client($config['realm'], $session->getLoop());
     $congestionManager->addTransportProvider(new PawlTransportProvider($config['trusted_url']));
     $congestionManager->on('open', function (ClientSession $session) {
         $session->subscribe("thruway.metaevent.procedure.congestion", [$this, "onCongestion"]);
     });
     $congestionManager->start(false);
 }
Ejemplo n.º 3
0
 /**
  *  Starts the open sequence
  * @param bool $startLoop
  */
 public function open($startLoop = true)
 {
     $this->client->start($startLoop);
 }
Ejemplo n.º 4
0
 /**
  *  Starts the open sequence
  */
 public function open()
 {
     $this->client->start();
 }
Ejemplo n.º 5
0
<?php

require __DIR__ . '/vendor/autoload.php';
use Thruway\ClientSession;
use Thruway\Peer\Client;
use Thruway\Transport\PawlTransportProvider;
$client = new Client("realm1");
$client->addTransportProvider(new PawlTransportProvider("ws://127.0.0.1:8080/ws"));
$title = $_GET['title'];
$message = $_GET['message'];
$type = $_GET['type'];
$notification['title'] = $title;
$notification['message'] = $message;
$notification['type'] = $type;
$notification = json_encode($notification);
echo "\n {$notification} \n";
//die();
$client->on('open', function (ClientSession $session) {
    global $notification;
    $session->publish('pcaudit.broadcastmessage', [$notification], [], ["acknowledge" => true])->then(function () {
        echo "Publish Acknowledged!\n";
        die;
    }, function ($error) {
        // publish failed
        echo "Publish Error {$error}\n";
        die;
    });
});
$client->start();
Ejemplo n.º 6
0
 public function start($startLoop = true)
 {
     parent::start($startLoop);
 }