kakajansh / echo

Laravel Echo for your Flutter apps.
MIT License
107 stars 68 forks source link

Connecting to presence channel problem #53

Open a7mdragab opened 2 years ago

a7mdragab commented 2 years ago

Hello, I have a problem with connecting to presence channel:

Laravel console:

L A R A V E L  E C H O  S E R V E R

version 1.6.2

⚠ Starting server in DEV mode...

✔  Running at localhost on port 6001
✔  Channels are ready.
✔  Listening for http events...
✔  Listening for redis events...

Server ready!

OWCJjy4o64iDbqMOAAAA joined channel: public_channel
Preparing authentication request to: http://localhost/app/public/index.php/api/v1
Sending auth request to: http://localhost/app/public/index.php/api/v1/broadcasting/auth

- Preparing authentication request to: http://localhost/app/public/index.php/api/v1
- Sending auth request to: http://localhost/app/public/index.php/api/v1/broadcasting/auth

- Preparing authentication request to: http://localhost/app/public/index.php/api/v1
- Sending auth request to: http://localhost/app/public/index.php/api/v1/broadcasting/auth

- OWCJjy4o64iDbqMOAAAA authenticated for: private-private-channel
- OWCJjy4o64iDbqMOAAAA joined channel: private-private-channel
- OWCJjy4o64iDbqMOAAAA authenticated for: presence-presence-channel.1
- 
Unable to join channel. Member data for presence channel missing ************************Here*********************

- OWCJjy4o64iDbqMOAAAA joined channel: presence-presence-channel.1

Laravel channels.php:

Broadcast::channel('private-channel.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});

Broadcast::channel('presence-channel.{id}', function ($user, $id) {
    return ['id'=>$id,'user'=>$user->name];
});

Laravel BroadcastServiceProvider:

public function boot()
    {
        Broadcast::routes(['middleware' => ['auth:sanctum']]);
        require base_path('routes/channels.php');
    }

Dart code:

echo!.join('presence-channel.1').here((users) {
      logger.e(jsonEncode(users));
    }).joining((user) {
      logger.e(jsonEncode(user));
    }).leaving((user) {
      logger.e(jsonEncode(user));
    }).listen('presence-channel PresenceEvent: ', (e) {
      logger.e(e);
    });
a7mdragab commented 2 years ago

Up

mosaw commented 2 years ago

did u used it in paid host ?

a7mdragab commented 2 years ago

did u used it in paid host ?

No, just trying locally

nguyenvanan18031993 commented 2 years ago

@a7mdragab Did you resolve it? I have the same trouble.