From 641332e5ba12b94e6f9aa7a2f4aa297d1ea2c64d Mon Sep 17 00:00:00 2001 From: "m.razaghi" Date: Thu, 20 Aug 2026 17:32:09 +0330 Subject: [PATCH] revert commit --- .env => .env.pusher | 0 .gitignore | 4 +-- app/Events/MatchEnded.php | 62 ++++++++++++++++----------------- app/Events/MatchStarted.php | 68 ++++++++++++++++++------------------- config/app.php | 2 +- routes/channels.php | 21 +----------- 6 files changed, 69 insertions(+), 88 deletions(-) rename .env => .env.pusher (100%) diff --git a/.env b/.env.pusher similarity index 100% rename from .env rename to .env.pusher diff --git a/.gitignore b/.gitignore index ce4783c..e4a8c41 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ /public/storage /storage/*.key /vendor -.env +.env.pusher .env.backup .env.production .phpunit.result.cache @@ -17,4 +17,4 @@ yarn-error.log /.fleet /.idea /.vscode -*.DS_Store \ No newline at end of file +*.DS_Store diff --git a/app/Events/MatchEnded.php b/app/Events/MatchEnded.php index 354337d..5e1d82e 100644 --- a/app/Events/MatchEnded.php +++ b/app/Events/MatchEnded.php @@ -1,32 +1,32 @@ matchId = $matchId; - } - - public function broadcastOn() - { - // ارسال پیام به کانال پرایوت بازی که هر دو نفر داخل آن هستند - return new PrivateChannel('pvp-match.' . $this->matchId); - } - - public function broadcastAs() - { - return 'match.ended'; - } -} +// +//namespace App\Events; +// +//use Illuminate\Broadcasting\InteractsWithSockets; +//use Illuminate\Broadcasting\PrivateChannel; +//use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; +//use Illuminate\Foundation\Events\Dispatchable; +//use Illuminate\Queue\SerializesModels; +// +//class MatchEnded implements ShouldBroadcastNow +//{ +// use Dispatchable, InteractsWithSockets, SerializesModels; +// +// public $matchId; +// +// public function __construct($matchId) +// { +// $this->matchId = $matchId; +// } +// +// public function broadcastOn() +// { +// // ارسال پیام به کانال پرایوت بازی که هر دو نفر داخل آن هستند +// return new PrivateChannel('pvp-match.' . $this->matchId); +// } +// +// public function broadcastAs() +// { +// return 'match.ended'; +// } +//} diff --git a/app/Events/MatchStarted.php b/app/Events/MatchStarted.php index 0ceef6f..58e7d5b 100644 --- a/app/Events/MatchStarted.php +++ b/app/Events/MatchStarted.php @@ -1,35 +1,35 @@ matchData = $matchData; - $this->ticketId = $ticketId; - } - - public function broadcastOn() - { - // ارسال پیام به کانال پرایوت مختص تیکت کاربری که در صف انتظار بود - return new PrivateChannel('matchmaking.' . $this->ticketId); - } - - public function broadcastAs() - { - // نام ایونتی که کاتلین باید به آن گوش دهد - return 'match.started'; - } -} +// +//namespace App\Events; +// +//use Illuminate\Broadcasting\InteractsWithSockets; +//use Illuminate\Broadcasting\PrivateChannel; +//use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; +//use Illuminate\Foundation\Events\Dispatchable; +//use Illuminate\Queue\SerializesModels; +// +//class MatchStarted implements ShouldBroadcastNow +//{ +// use Dispatchable, InteractsWithSockets, SerializesModels; +// +// public $matchData; +// public $ticketId; +// +// public function __construct($matchData, $ticketId) +// { +// $this->matchData = $matchData; +// $this->ticketId = $ticketId; +// } +// +// public function broadcastOn() +// { +// // ارسال پیام به کانال پرایوت مختص تیکت کاربری که در صف انتظار بود +// return new PrivateChannel('matchmaking.' . $this->ticketId); +// } +// +// public function broadcastAs() +// { +// // نام ایونتی که کاتلین باید به آن گوش دهد +// return 'match.started'; +// } +//} diff --git a/config/app.php b/config/app.php index 8cdb290..343bf6f 100644 --- a/config/app.php +++ b/config/app.php @@ -165,7 +165,7 @@ return [ */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, - App\Providers\BroadcastServiceProvider::class, + // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, App\Providers\FortifyServiceProvider::class, diff --git a/routes/channels.php b/routes/channels.php index 9afc718..5d451e1 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Broadcast; | Broadcast Channels |-------------------------------------------------------------------------- | -| Here you may register all of the Events broadcasting channels that your +| Here you may register all of the event 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,22 +16,3 @@ 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(); -});