pushd icon indicating copy to clipboard operation
pushd copied to clipboard

Send notification to one user

Open mennopruijssers opened this issue 11 years ago • 5 comments

The docs mention publishing an event to all subscribers... Is is also possible to publish it to only one user? If not: Whats the best practice to emulate this behavior? Suffix the event-name with the user-id and subscribe each user also on it's "own" events?

mennopruijssers avatar Jun 14 '13 06:06 mennopruijssers

Currently, the only solution I found is to create an event name with the subscriber id, but I think it's not optimal because if there is 1 000 000 subscribers then there is 1 000 000 event created, which takes a lot of memory. It would be very cool if pushing directly to a subcriber id was possible. :)

Lloyd66 avatar Jun 14 '13 11:06 Lloyd66

It is the correct solution to this problem. The number of events doesn't matter, the cost for each event is very low.

Keep in mind that subscribers are devices not distinct users of your application. The same user can have several devices, can change device or restore its device which would change it's subscriber id. Having on event name per user of your application will handle all those situations gracefully.

rs avatar Jun 14 '13 11:06 rs

I think the cost is rather higher due to memory usage by Redis within this approach, as Llloyd66 already mentioned. Most use cases we see, don't have that model of user/several devices, more have just a 1-on-1 relationship between user/device. Would be great to see it as an optional way of doing push with pushd.

melv1n avatar Jun 14 '13 12:06 melv1n

The cost in term of memory is neglectable and will never be a problem. Using the subscriber id for communication is not reliable because EVEN for the same device, this id is subject to change. The only reliable meeting point to communicate with a user/device/whatever is to use an event name (which should have been named channel).

rs avatar Jun 14 '13 12:06 rs

See pullrequest #32

mennopruijssers avatar Jun 16 '13 10:06 mennopruijssers