PHP code example of voryx / wamppost

1. Go to this page and download the library: Download voryx/wamppost 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/ */

    

voryx / wamppost example snippets



reate an HTTP server on port 8181
$wp = new \WampPost\WampPost('realm1', null, '127.0.0.1', 8181);

// add a transport to connect to the WAMP router
$wp->addTransportProvider(new \Thruway\Transport\PawlTransportProvider('ws://127.0.0.1:9090/'));

// start the WampPost client
$wp->start();


Thruway\Peer\Router;
use Thruway\Transport\RatchetTransportProvider;

$router = new Router();

//////// WampPost part
// The WampPost client
// create an HTTP server on port 8181 - notice that we have to
// send in the same loop that the router is running on
$wp = new WampPost\WampPost('realm1', $router->getLoop(), '127.0.0.1', 8181);

// add a transport to connect to the WAMP router
$router->addTransportProvider(new Thruway\Transport\InternalClientTransportProvider($wp));
//////////////////////

// The websocket transport provider for the router
$transportProvider = new RatchetTransportProvider("127.0.0.1", 9090);
$router->addTransportProvider($transportProvider);
$router->start();