Support the ongoing development of Laravel.io →
posted 6 months ago
Laravel
0

My goal is to send data (in this case, messages) to a group of users, and I'm specifically referring to a particular group with an ID of 1.

0

How are you broadcasting the event to the channel? What is on this route: "trip.event"

0

Route::post('/tripEvent', function (Request $request){ TripEvent::dispatch($request->trip_id,$request->message); })->name('trip.event');

$trip_id definitely has the value 1 (which I also tried to enter as a constant). Let's say I have a certain group of users that belongs to $trip = 1 and I want them to receive page changes without refreshing it. Also im using soketi for broadcast server

Last updated 6 months ago.
0

thank you in advance for your help with this example I'm trying to understand how it works in order to send more complicated data in the future. I would like to create an interface that does not require refreshing the page for any user to see changes on the page. I don't understand how exactly this $trip_id parameter is passed in the channel.

Last updated 6 months ago.
0

Have you set-up the correct broadcastOn channel for TripEvent?.

Also, the authorization function of the channel must always return a boolean:

So it should look more like this:

Broadcast::channel('privateTrip.{tripId}', fn ($tripId) => $tripId == 1);
// Broadcast::channel('privateTrip.{tripId}', function ($tripId) { return $tripId == 1; }); // Or if you are using an older version of php

d1n0s liked this reply

1

OK. ITS WORKS <3 THANKS BRO NOW I KNOW HOW TO USE THAT :3

wizzymore, d1n0s liked this reply

2

Sign in to participate in this thread!

Eventy

Your banner here too?

Grzegorz Kubok d1n0s Joined 28 Sep 2023

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.