Cuando me conecto a través de Channel en lugar de PrivateChannel, todo funciona como se esperaba. Pero cuando me conecto a través de PrivateChannel, de repente dejo de recibir eventos dentro de mi javascript. Mis eventos aparecen dentro del panel de WebSocket. Despacho mi evento así:
FullRecipeSaved::dispatch($recipe, $rld);FullRecipeSaved.php
class FullRecipeSaved implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; public $recipe; public $recipeLiftingDate; public function __construct(Recipe $recipe, RecipeLiftingDate $recipeLiftingDate) { $this->recipe = $recipe; $this->recipe = $recipeLiftingDate; } /** * Get the channels the event should broadcast on. * * @return \Illuminate\Broadcasting\Channel|array */ public function broadcastOn() { return new PrivateChannel('recipe'); } /** * The event's broadcast name. * * @return string */ public function broadcastAs() { return 'recipe.update'; } }canales.php
<?php Broadcast::channel('recipe', function($recipe, $recipeLiftingDate) { return true; });bootstrap.js
window.Echo = new Echo({ broadcaster: "pusher", key: process.env.MIX_PUSHER_APP_KEY, cluster: process.env.MIX_PUSHER_APP_CLUSTER, wsHost: window.location.hostname, wsPort: 6001, forceTLS: false, disableStats: false, authEndpoint: GLOBAL.appUrl, });GLOBAL.appUrl es APP_URL del archivo .env http://localhost/****/public). Y este es el código que estoy usando para conectarme al canal.
window.Echo.private("recipe").listen( ".recipe.update", (event) => { console.log("ok"); } );