PHP code example of rx / thruway-client

1. Go to this page and download the library: Download rx/thruway-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rx / thruway-client example snippets


use Rx\Observable;
use Rx\Thruway\Client;

 'realm1');

$wamp->call('add.rpc', [1, 2])
    ->map(function (Thruway\Message\ResultMessage $r) {
        return $r->getArguments()[0];
    })
    ->subscribe(function ($r) {
        echo $r;
    });

$wamp->register('add.rpc', function ($a, $b) { return $a + $b; })->subscribe();

$wamp->publish('example.topic', 'some value');
$wamp->publish('example.topic', Observable::interval(1000)); // you can also publish an observable

$wamp->topic('example.topic')
    ->map(function(Thruway\Message\EventMessage $m) {
        return $m->getArguments()[0];
    })
    ->subscribe(function ($v) { echo $v; });