V
V
Valeriu Vodnicear2019-04-02 03:48:39
Laravel
Valeriu Vodnicear, 2019-04-02 03:48:39

How to work with Swoole in Laravel?

Does anyone have experience with the Laravel Swoole package ?
I installed everything according to the instructions, the project started:
5ca2afa2459c8440076391.png
I read the Wiki on GitHub, and in paragraph 7, an example of routes is given:

routes/websocket.php
Websocket::on('connect', function ($websocket, Request $request) {
    // called while socket on connect
    $websocket->emit('message', 'hello world');
});

Websocket::on('disconnect', function ($websocket) {
    // called while socket on disconnect
});

Websocket::on('example', function ($websocket, $data) {
    $websocket->emit('message', 'response from example action');
});

Websocket::on('message', function ($websocket, $data) {
    $websocket->emit('message', 'response from message action');
    // $websocket->push('message', 'response from message action by push');
});

Websocket::on('test', 'Users/[email protected]');
Websocket::on('joinToRoom', 'Users/[email protected]');

And right now, when connecting (I use this for tests) hello world, a message will appear, but then, no matter what message I send, nothing comes in response. Why is that?
How to properly make routes and controllers when using swoole in laravel ?
Maybe there are some examples...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question