Is it possible to specify the member id of an event so that only that member would receive the event?
If for instance I want to send a notification to a user (who's user ID I know) how would I do that? I'm storing the member/user ID in the presence authentication -
$pusher->presence_auth($_POST['channel_name'], $_POST['socket_id'], $user_id)
, $user_data);
I want to be able to trigger an event for a specific user_id
$pusher->trigger( 'presence-test', 'test_event', $data, $socket_id );
Is it possible?
Any advice appreciated, thanks!
You can't send events to specific users/clients on a channel.
The best way to do this would be to have a private-
channel per user so that you can send information only to them. The fact they're private also means that you can ensure only the expected user subscribes (see authenticating users).
In your case the channel name can be 'private-' + user_id
.
You can then get the user to subscribe to that channel and publish to that channel from the server.
来源:https://stackoverflow.com/questions/15591424/pusher-send-presence-event-to-specific-member