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

Isa*_*ira 6 php laravel

我正在创建一个随机的实时聊天,比如"聊天".

我无法使用等待列表在私有线程中连接两个随机用户.使用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);
});
Run Code Online (Sandbox Code Playgroud)

loi*_*pez 0

我认为您可以在事件调度后创建一个频道并将用户关联起来。

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

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

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