Problem
I can confirm that Pusher API is receiving the message. I saw in Debug console of Pusher website. But listen callback is not working at all.
I got it working. Below is the correct code. I hope this will be useful to others for sending real time messaging.
Js Work
Controller Code
broadcast(new SendMessageEvent("Hi", 1))->toOthers();
//Here 1 is recepient ID
Event Code
class SendMessageEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $Message;
private $UserID;
public function __construct($message, $RecepientID)
{
$this->Message = $message;
$this->UserID = $RecepientID;
}
public function broadcastOn()
{
return new PrivateChannel('SendMessageChannel.' . $UserID);
}
}