voryx / Thruway

PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging Protocol) for Real-Time Application Messaging
MIT License
676 stars 117 forks source link

method does not start on prefix #318

Closed danilkinanton closed 4 years ago

danilkinanton commented 5 years ago

Why method does not start on prefix ($session->subscribe('query.update.' ...)?

How can i run function on subscribe event only with some prefix? I need to check the hash and decline the subscription if it is wrong.

public function onSessionStart($session, $transport)
    {
        $context = new \React\ZMQ\Context($this->getLoop());
        $pull = $context->getSocket(\ZMQ::SOCKET_PULL);
        $pull->bind('tcp://127.0.0.1:8081');
        $pull->on('message', [$this, 'onBlogEntry']);
        $session->subscribe('query.update.', function ($args, $argsKw, $details, $publicationId) {
            $value = isset($args[0]) ? $args[0] : '';
            echo 'Received ' . json_encode($value) . ' on topic ' . $details->topic . PHP_EOL;
        },[ 'match' => 'prefix' ]);
    }
var connection = new autobahn.Connection({
            url: 'ws://********:8080',
            realm: 'realm1',
            authmethods: ['ipauth'] // Tell the router that we want to use the ipauth auth provider
        });
        function onevent(args) {
            console.log("Event:", args[0]);
        }

        connection.onopen = function (session, details) {
            var m = "Congrats " + details.authid + "! You're connected to the WAMP server!";

            console.log(m);

            session.subscribe('query.update.123',onevent);
        };
        connection.onclose = function (reason, details) {
            console.log("Connection Closed: ", reason, details);

        };

        connection.open();
mbonneau commented 4 years ago

@danilkinanton You would need to look into the AuthorizationHandler - possibly implement a custom one. Closing this issue due to inactivity.