Skip to content

Latest commit

 

History

History
49 lines (42 loc) · 1.1 KB

README.md

File metadata and controls

49 lines (42 loc) · 1.1 KB

yii2-wamp-router

Installation

It is recommended that you install the Gearman library through composer. To do so, add the following lines to your composer.json file.

{
    "require": {
       "filsh/yii2-wamp": "dev-master"
    }
}

Examples

// configure component
'components' => [
    'wampRouter' => [
        'class' => 'filsh\wamp\components\WampRouter',
        'realm' => 'realm',
        'host' => '172.17.0.20',
        'port' => '8000',
    ],
  'wamp' => [
        'class' => 'filsh\wamp\Module',
        'wampRouter' => 'wampRouter',
        'runnerMap' => [
            ...
        ]
    ]
],

// run examples
Yii::$app->wampRouter->connect(function(Connection $connection, ClientSession $session) {
    $session->call('com.myapp.add2', [2, 3])
        ->then(function (CallResult $result) use($connection) {
                echo $result;
                $connection->close();
            },
            function (ErrorMessage $error) use($connection) {
                echo $error;
                $connection->close();
            }
        );
});