filsh/yii2-wamp

Extension for WAMP(Web Application Messaging Protocol)

Installs: 91

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 4

Forks: 0

Type:yii2-extension

dev-master 2015-09-17 22:53 UTC

This package is auto-updated.

Last update: 2024-10-29 04:09:25 UTC


README

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();
            }
        );
});