56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\Channel;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PresenceChannel;
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class VirtualMachineStatusChanged implements ShouldBroadcast
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
public $message;
|
|
public $vmId;
|
|
public $status;
|
|
public $userId;
|
|
|
|
/**
|
|
* Create a new event instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($userId, $vmId, $status, $message)
|
|
{
|
|
$this->userId = $userId;
|
|
$this->vmId = $vmId;
|
|
$this->status = $status;
|
|
$this->message = $message;
|
|
}
|
|
|
|
/**
|
|
* Get the channels the event should broadcast on.
|
|
*
|
|
* @return \Illuminate\Broadcasting\Channel|array
|
|
*/
|
|
public function broadcastOn()
|
|
{
|
|
// Broadcast on a private channel for the user
|
|
return new PrivateChannel('user.' . $this->userId);
|
|
}
|
|
|
|
/**
|
|
* The event's broadcast name.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function broadcastAs()
|
|
{
|
|
return 'vm.status.changed';
|
|
}
|
|
}
|