Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to extend SimpleWsRouter to handle functions from autobahn? #363

Open
kpebron opened this issue Nov 16, 2022 · 0 comments
Open

How to extend SimpleWsRouter to handle functions from autobahn? #363

kpebron opened this issue Nov 16, 2022 · 0 comments

Comments

@kpebron
Copy link

kpebron commented Nov 16, 2022

I am using Laravel 8 and trying to integrate Thruway. Below is the code copied from SimpleWSRouter.php and added in my src.

        $port = 6001;

        $router = new Router();

        $transportProvider = new RatchetTransportProvider("127.0.0.1", $port);

        $router->addTransportProvider($transportProvider);

        $router->start();

autobahn

        var connection = new autobahn.Connection({
            url: 'ws://localhost:6001',
            realm: 'realm1'
        });

        connection.onopen = function(session) {

            // 1) subscribe to a topic
            function onevent(args) {
                console.log("Event:", args[0]);
            }
            session.subscribe('com.myapp.hello', onevent);

            // 2) publish an event
            session.publish('com.myapp.hello', ['Hello, world!']);

            // 3) register a procedure for remoting
            function procedureRegister(args) {
                return args[0] + " " + args[1];
            }
            session.register('com.myapp.pr1', procedureRegister);

            // 4) call a remote procedure
            session.call('com.myapp.pr1', ["FNAME", "LNAME"]).then(
                function(res) {
                    console.log("Result:", res);
                }
            );
        };

        connection.open();

I can connect without problem but I dont know what to do next after this.

What I know:

session.subscribe: subscribe to a channel (in this case channel name is "com.myapp.hello")
session.publish: Probably used to send message from user to user using the channel name.

What I dont know:
session.register and session.call. I also dont know where should I add realm in my server to connect the code. I think realm1 is default realm.

I actually came from ratchet. with ratchet, I can register a websocket server to work on open, close, message, etc. However Ratchet and Autobahn is not compatible ( with wampv1 and 2) etc.

Any help would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant