revert commit

This commit is contained in:
m.razaghi
2026-08-20 17:32:09 +03:30
parent 76d9246e0e
commit 641332e5ba
6 changed files with 69 additions and 88 deletions

View File

2
.gitignore vendored
View File

@@ -5,7 +5,7 @@
/public/storage
/storage/*.key
/vendor
.env
.env.pusher
.env.backup
.env.production
.phpunit.result.cache

View File

@@ -1,32 +1,32 @@
<?php
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';
}
}
//
//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';
// }
//}

View File

@@ -1,35 +1,35 @@
<?php
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';
}
}
//
//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';
// }
//}

View File

@@ -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,

View File

@@ -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();
});