1

I'm trying to make a platform where there is a list of users, When user-A clicks on user-B a chat between the two should be initialised.

So I'm wondering what the best method would be to go about this.. For the moment I've come up with this.

Every user enters the presence-channel.

Every user get's it's own private-notications-channel

  • ( private-notifications-A, private-notifications-B, ... )

But now I'm stuck, Should I create a private-chat-userA-userB channel? Do I even need the notifications channel?

This is my PHP code that create's the private channel

public function chat(PusherManager $pusher, Request $request)
{
    $sender = Auth::user()->id;
    $receiver = (int) $request->get('id');

    if($sender !== $receiver)
    {
        $data = [
            "sender" => Auth::user(),
            "receiver" => User::find($receiver)
        ];

        $pusher->trigger("private-chat-".$sender . "-" . $receiver, "message", $data);
    }
}

So I'm wondering how do I subscribe the 2 users to the private-chat-channel for them?

Community
  • 1
  • 1
Miguel Stevens
  • 8,631
  • 18
  • 66
  • 125

0 Answers0