mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-20 08:42:03 -05:00
74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* NOTICE OF LICENSE.
|
|
*
|
|
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
|
* The details is bundled with this project in the file LICENSE.txt.
|
|
*
|
|
* @project UNIT3D
|
|
*
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
|
* @author singularity43
|
|
*/
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Message;
|
|
use Illuminate\Broadcasting\Channel;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
|
|
|
class Chatter implements ShouldBroadcastNow
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
/**
|
|
* Message details.
|
|
*
|
|
* @var Message
|
|
*/
|
|
public $echoes;
|
|
public $target;
|
|
public $type;
|
|
public $message;
|
|
public $ping;
|
|
public $audibles;
|
|
|
|
/**
|
|
* Create a new event instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($type, $target, $payload)
|
|
{
|
|
$this->type = $type;
|
|
if($type == 'echo') {
|
|
$this->echoes = $payload;
|
|
} else if($type == 'audible') {
|
|
$this->audibles = $payload;
|
|
} else if($type == 'new.message') {
|
|
$this->message = $payload;
|
|
} else if($type == 'new.bot') {
|
|
$this->message = $payload;
|
|
} else if($type == 'new.ping') {
|
|
$this->ping = $payload;
|
|
}
|
|
$this->target = $target;
|
|
}
|
|
|
|
/**
|
|
* Get the channels the event should broadcast on.
|
|
*
|
|
* @return Channel|array
|
|
*/
|
|
public function broadcastOn()
|
|
{
|
|
// $this->dontBroadcastToCurrentUser();
|
|
|
|
return new PrivateChannel('chatter.'.$this->target);
|
|
}
|
|
|
|
} |