Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Presence Channel hash error #192

@niku98

Description

@niku98

I got this error when trying to join a presence channel.

Connection id 555337873.285811191 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-Users.2"}
1351: connection id 555337873.285811191 received message: {"event":"pusher:subscribe","data":{"auth":"333511:f499859e22e3764a511e
780d515ec70447d495f74d7c132be5e5d7bfbfe81312","channel_data":"{\"user_id\":1}","channel":"presence-Rooms.1.Chat"}}.
Exception `ErrorException` thrown: `Undefined property: stdClass::$user_info`
1351: exception `ErrorException` thrown: `Undefined property: stdClass::$user_info`.

After read source code I found problem but don't know how to fix. Problem is in BeyondCode\LaravelWebSockets\WebSockets\Channels\PresenceChannel::getHash, there is no $user_info property in stdClass $channelData, only $user_id

protected function getHash(): array
{
    $hash = [];

    foreach ($this->users as $socketId => $channelData) {
        $hash[$channelData->user_id] = $channelData->user_info;
    }

    return $hash;
}

Below is my code to join channel, send, receive whisper

// This block code in created() - Vue component
this.echos.chat = this.Echo.join('Rooms.' + this.room.id + '.Chat').joining(e => {
    console.log(e);
}).listenForWhisper('typing', e => {
    console.log(e.name);
});
// A method in component
whisperTyping(){
    this.echos.chat.whisper('typing', {
        name: this.curUser.name
    });
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions