Sending events to authenticated users
When your application client authenticates users on their Pusher Channels connection, your application server is able to send events to users knowing their user id without them having to subscribe to channels in advance. An example follows.
Check:
- The Client user authentication docs for information on how to authenticate a user on the client.
- The Events docs for information on how to handle events sent to authenticated users on the client.
- The Server user authentication docs for information on how to create a user authentication endpoint.
pusher.sendToUser("user-id", "event-name", { message: "hello world" });
$pusher->sendToUser('user-id', 'event-name', [ 'message' => 'hello world' ]);