<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class TypingMessageEvent implements ShouldBroadcast
{
	use Dispatchable, InteractsWithSockets, SerializesModels;
	
	public $userId;
	public $conversationId;
	
	public function __construct($userId, $conversationId)
	{
		$this->userId = $userId;
		$this->conversationId = $conversationId;
	}
	
	public function broadcastWith()
	{
		return [
			'userId' => $this->userId,
		];
	}
	
	public function broadcastOn()
	{
		return new PrivateChannel('chat.conversion.' . $this->conversationId);
	}
}
