@charlescook Where are you importing Echo? As it will only be undefined if it’s not imported.
Dec 1, 2024
4
Level 1
Breeze, Vue, Inertia SSR, ReferenceError: Echo is not defined
I'm just trying out SSR now, and this error wont go away. Echo or window.Echo in .vue file. window.Echo return a ReferenceError: window is not defined.
ssr.js file line 2965 :
const channel = Echo.channel('AdminChannel');
returns error
but no error from line 654 :
const UserChannel = Echo.private("UserChannel");
Level 1
Well there were more bugs than I thought. Double Rendering of Text when leaving channels and coming back. Fix, if others need it: Start chat .vue:
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
function open_chat() {
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'pusher',
key: '55555555555',
cluster: 'mt1',
forceTLS: true,
enabledTransports: ['wss', 'ws'],
});
channel = window.Echo.channel('AdminChannel');
channel.listen('AdminEvent', (e) => {}
leave channel isn't enough to prevent doubles. Close chat:
window.Echo.leaveChannel('AdminEvent');
window.Echo.disconnect();
php controller:
broadcast(new AdminEvent($room_id, $user_id, $message))->toOthers();
Event:
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
class AdminEvent implements ShouldBroadcastNow
Please or to participate in this conversation.