Revert "revert commit"

This reverts commit 641332e5ba.
This commit is contained in:
m.razaghi
2026-08-20 17:37:48 +03:30
parent 641332e5ba
commit 6a204c69ac
6 changed files with 88 additions and 69 deletions

View File

@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Broadcast;
| Broadcast Channels
|--------------------------------------------------------------------------
|
| Here you may register all of the event broadcasting channels that your
| Here you may register all of the Events broadcasting channels that your
| application supports. The given channel authorization callbacks are
| used to check if an authenticated user can listen to the channel.
|
@@ -16,3 +16,22 @@ use Illuminate\Support\Facades\Broadcast;
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
// کانال انتظار برای پیدا شدن حریف
Broadcast::channel('matchmaking.{ticketId}', function ($user, $ticketId) {
// در این مرحله، هر کاربری که لاگین باشد و تیکت خودش را داشته باشد اجازه دسترسی دارد
return true;
});
// کانال داخل بازی (برای ارسال پایان بازی یا تغییرات زنده)
Broadcast::channel('pvp-match.{matchId}', function ($user, $matchId) {
$match = \App\Models\PvpMatch::find($matchId);
if (!$match) {
return false;
}
// فقط اگر این کاربر یکی از دو بازیکنِ این مسابقه باشد، اجازه دسترسی به کانال را دارد
return $match->players()->where('user_id', $user->id)->exists();
});