mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-28 02:50:39 +00:00
test websocket connection
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Settings\Controllers;
|
||||
|
||||
use Domain\Settings\Events\TestWebsocketConnectionEvent;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class TestWebsocketConnectionController
|
||||
{
|
||||
public function __invoke(): JsonResponse
|
||||
{
|
||||
TestWebsocketConnectionEvent::dispatch(
|
||||
auth()->user()
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'type' => 'success',
|
||||
'message' => 'The websocket test event was successfully dispatched.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace Domain\Settings\Events;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||
|
||||
class TestWebsocketConnectionEvent implements ShouldBroadcastNow
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
public User $user,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The event's broadcast name.
|
||||
*/
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'TestWebsocketConnection';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*/
|
||||
public function broadcastOn(): PrivateChannel
|
||||
{
|
||||
return new PrivateChannel("App.Users.Models.User.{$this->user->id}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user