Hi, I’m trying to implement a chat with events, livewire and pusher.
Everything works fine when the channel is public but when I try to switch to a presence channel I get this error:
LaravelEcho.js:38 Uncaught TypeError: Echo.join(...)[event_name] is not a function
at LaravelEcho.js:38
at Array.forEach (<anonymous>)
at LaravelEcho.js:6
at MessageBus.js:17
at Array.forEach (<anonymous>)
at MessageBus.value (MessageBus.js:16)
at Object.call (HookManager.js:38)
at Object.callHook (Store.js:120)
at new Component (index.js:47)
at index.js:83
Event
class ChatSendMessage implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $conversation;
public $userDestination;
public function __construct($conversationId, $userDestination)
{
$this->conversation = $conversationId;
$this->userDestination = $userDestination;
}
public function broadcastOn()
{
return new PresenceChannel('chat-'.$this->conversation);
}
}
Routes Channel
Broadcast::channel('chat-{id}', function ($user) {
return $user;
});
LIVEWIRE COMPONENT
protected $listeners = ['echo-presence:chat-1,ChatSendMessage' => 'mensajeRecibido'];
public function mensajeRecibido() // evento para el tiempo real
{
info('ok');
}
Any idea why I get this error?