Laravel-swoole: about broadcast

Created on 22 Feb 2019  ·  8Comments  ·  Source: swooletw/laravel-swoole

Websocket::broadcast()->emit('res', $data);

It works on version 2.5.0, not works on version 2.6.4

bug

Most helpful comment

This has been fixed in the newest release v2.6.5.

All 8 comments

Please provide more detailed info about this issue.

PHP version : 7.3.2
Laravel version : 5.7.27
swooletw/laravel-swoole package version : 2.6.4

+-----------------+--------------------------------------------------+
| Name            | Value                                            |
+-----------------+--------------------------------------------------+
| PHP Version     | 7.3.2-3+ubuntu16.04.1+deb.sury.org+1             |
| Swoole Version  | 4.2.13                                           |
| Laravel Version | 5.7.27                                           |
| Listen IP       | 127.0.0.1                                        |
| Listen Port     | 1215                                             |
| Server Status   | Online                                           |
| Reactor Num     | 2                                                |
| Worker Num      | 2                                                |
| Task Worker Num | 2                                                |
| Websocket Mode  | On                                               |
| PID             | 4775                                             |
| Log Path        | /var/www/hell/storage/logs/swoole_http.log       |
+-----------------+--------------------------------------------------+


  • [ ] routes\websocket.php
Websocket::on('test', '\App\Http\Controllers\TestController@socket');


  • [ ] app\Http\Controllers\TestController.php
namespace App\Http\Controllers;

use SwooleTW\Http\Websocket\Facades\Websocket;

class TestController extends Controller
{
    public function socket($data)
    {
        // It works!
        Websocket::emit('message', $data);

        // It doesn't work!
        Websocket::broadcast()->emit('message', $data);

        // It didn't proccess anything after I add broadcast method.
    }
}

What's your definition for 'not working'? Do you mean that clients can't receive messages? Are there any error messages?

Yes, the clients cannot receive message. It's empty.

Hi @savemydream ,

This bug has been confirmed in v2.6.4. This will be fixed in the next release.

Thank you so much!

This has been fixed in the newest release v2.6.5.

@albertcht Broadcast is not working for me on Lumen however emiting works fine.

Was this page helpful?
0 / 5 - 0 ratings