php - 如何使用 Laravel Broadcasting 在一个线程中连接两个随机的人

标签 php laravel

我正在创建一个随机实时聊天,例如 Omegle。

我无法使用等待列表在私有(private)线程中连接两个随机的人。使用 Laravel BroadcastingLaravel Job 最好的方法是什么?

例如:

Route::get('/start', function () {
    // add me to the wait list
    // wait for another person
    // find another person
    // remove me and another person from the wait list

    // dispatch event
    App\Events\AnotherPersonFound::dispatch($anotherPerson, $threadId);
});

最佳答案

我认为您可以在调度事件后创建一个 channel 并与用户关联。

参见:https://laravel.com/docs/5.7/broadcasting#presence-channels

您还可以使用以下方式发送有关人与人之间新匹配的通知:

https://laravel.com/docs/5.7/broadcasting#notifications

关于php - 如何使用 Laravel Broadcasting 在一个线程中连接两个随机的人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52690535/

相关文章:

mysql - 在数据库 Laravel 5.2 中插入记录的最佳、高效和专业的方式是什么

php - 如何捕获由 mail() 引起的错误?

php - 如果mysql不存在则插入值

javascript - Laravel 5.5 artisan 服务器上的 AJAX 404 错误

mysql - 如何在laravel中生成唯一的序列号

php - 从模型中获取所有在数据透视表 Laravel 5 中没有条目的记录

javascript - PHP 和 AJAX 不工作

php - Paypal:实例化交易后更改金额

php - Codeigniter URI 路由和安全

javascript - Laravel - 如何将 Blade View 文件中的某些参数值发送到 Controller ?