getClient() public method

public getClient ( ) : Client
return Thruway\Peer\Client
 public function testReplaceOrphanedSession()
 {
     $this->_testResult = null;
     $this->_error = null;
     $this->_conn->on('open', function (\Thruway\ClientSession $session) {
         $this->_conn->getClient()->getCallee()->register($session, 'com.example.orphan_testing', array($this, 'callOrphanTest'), ['replace_orphaned_session' => 'no'])->then(function ($res = null) use($session) {
             $this->_error = 'OrphaningClient not registered';
             $this->_conn->close();
         }, function ($msg = null) use($session) {
             if ($msg instanceof \Thruway\Message\ErrorMessage) {
                 if ($msg->getErrorURI() != 'wamp.error.procedure_already_exists') {
                     $this->_testResult = $msg->getErrorURI();
                     $this->_conn->close();
                 } else {
                     $this->_conn->getClient()->getCallee()->register($session, 'com.example.orphan_testing', array($this, 'callOrphanTest'), ['replace_orphaned_session' => 'yes'])->then(function () use($session) {
                         $session->call('com.example.orphan_testing', [])->then(function ($res) {
                             $this->_conn->close();
                             $this->_testResult = "resolve";
                         }, function ($error = null) {
                             if ($error instanceof \Thruway\Message\ErrorMessage) {
                                 $this->_testResult = $error->getErrorURI();
                             } else {
                                 $this->_testResult = "rejected";
                             }
                             $this->_conn->close();
                         });
                     });
                 }
             }
         });
     });
     $this->_conn->open();
     $this->assertNull($this->_error, "Error was {$this->_error}");
     $this->assertEquals("resolve", $this->_testResult);
 }
Esempio n. 2
0
 public function testCall()
 {
     $this->_conn->on('open', function (\Thruway\ClientSession $session) {
         $add2 = function ($args, $kwargs, $details) {
             $this->_testCallerId = $details["caller"];
             $this->_testAuthId = $details["authid"];
             $this->_testAuthMethod = $details["authmethod"];
             //                    $this->_testAuthRole = $details["authrole"];
             return $args[0] + $args[1];
         };
         $session->register('com.example.disclosecallertest', $add2, ['disclose_caller' => true])->then(function () use($session) {
             $session->call('com.example.disclosecallertest', [1, 2])->then(function ($res) {
                 $this->_conn->close();
                 $this->_testResult = $res;
             }, function ($error) {
                 $this->_conn->close();
                 $this->_error = $error;
             });
         });
     });
     $this->_conn->getClient()->setAuthId("*****@*****.**");
     $this->_conn->open();
     $this->assertNull($this->_error, "Got this error when making an RPC call: {$this->_error}");
     $this->assertEquals(3, $this->_testResult[0]);
     $this->assertNotEmpty($this->_testCallerId);
     $this->assertEquals("*****@*****.**", $this->_testAuthId);
     $this->assertEquals("simplysimple", $this->_testAuthMethod);
 }
Esempio n. 3
0
 public function setUp()
 {
     $this->_testArgs = null;
     $this->_testResult = null;
     $this->_error = null;
     $this->_connOptions = ["realm" => 'testRealm', "url" => 'ws://127.0.0.1:8090', "max_retries" => 0];
     $this->_conn = new \Thruway\Connection($this->_connOptions);
     $this->_loop = $this->_conn->getClient()->getLoop();
     $this->_conn2 = new \Thruway\Connection($this->_connOptions, $this->_loop);
 }
 public function thePartitionedRPC2($args)
 {
     $this->_result .= "[start 2(" . $args[0] . ")]";
     $deferred = new \React\Promise\Deferred();
     $loop = $this->_conn->getClient()->getLoop();
     $loop->addTimer(1, function () use($deferred, $args) {
         $deferred->resolve("[RPC 2(" . $args[0] . ")]");
     });
     return $deferred->promise();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //$simulations = Simulation::join('ItemSet as I', 'I.Id', '=', 'Simulation.Id')
     /*->where('Simulation.State', '!=', 0)
       ->where('Simulation.State', '!=', 3)*/
     //->select('I.*')
     //->first();
     //var_dump($simulations);
     //$s = Simulation::find('C4E3A3FB-9CE8-4FC6-81B9-5994B08EF1B2');
     //$this->info($s->State);
     $connection = new Connection(['realm' => "realm1", 'url' => "ws://127.0.0.1:8081/ws"]);
     $connection->on('open', function (ClientSession $session) use($connection) {
         $session->subscribe('com.gosmartsimulation.identify', function ($args) {
             $server_id = $args[0];
             $server_name = $args[1];
             $this->responses[$server_id] = true;
             $this->server_names[$server_id] = $server_name;
         });
         $this->tick($connection->getClient()->getLoop(), $session);
     });
     $connection->open();
     //Mail::send('emails.failed_sim', ['guid' => '1'], function ($message) {
     //  $message->to('*****@*****.**', 'Phil Weir')->subject('Simulation failed');
     //});
 }
 public function testCheckHelloDetails()
 {
     $this->_error = null;
     $this->_testResult = null;
     $roleInfo = null;
     $this->_conn->on('open', function (\Thruway\ClientSession $session) use(&$roleInfo) {
         $roleInfo = $this->_conn->getClient()->getRoleInfoObject();
         $session->call('com.example.get_hello_details')->then(function ($r) use($session) {
             $this->_testResult = $r;
             $session->close();
         }, function ($r) use($session) {
             $this->_error = $r;
             $session->close();
         });
     });
     $this->_conn->open();
     $this->assertNull($this->_error, "Got this error when making an RPC call: {$this->_error}");
     $this->assertEquals($roleInfo, $this->_testResult[0]);
 }