Server Sent Event to a specific user

96 views
Skip to first unread message

Thai Tran

unread,
Dec 29, 2013, 1:54:44 PM12/29/13
to django...@googlegroups.com
Hi,

I am working on a message sending/reading app atm. Is there any way to push a message to a particular user session by using Redis and SSE ? I am using the tutorial at https://github.com/fcurella/django-push-demo and it works great with the current setup (which means I can send the whole bunks of new messages to all users but this is not what I wish for, obviously). When a user A composes a message and send to user B, how can I just "push" that new message to that particular user B ?

Nevio Vesic

unread,
Dec 29, 2013, 2:03:29 PM12/29/13
to django...@googlegroups.com
Well You can always send custom events for some specific channel. Example:

socket.on("global_event", function(channel, data) {});
socket.on("user_XYZ", function(channel, data) {});

emit_to_channel('some_room', 'gobal_event', 'hello')
emit_to_channel('some_room', 'user_XYZ', 'hello XYZ')

I understand this is not the most secure way but you can ensure additional encryption like hashing on every request or shit like that or even have every user connects to its own "secured" channel. 

Hope this helps.


Hi,

I am working on a message sending/reading app atm. Is there any way to push a message to a particular user session by using Redis and SSE ? I am using the tutorial at https://github.com/fcurella/django-push-demo and it works great with the current setup (which means I can send the whole bunks of new messages to all users but this is not what I wish for, obviously). When a user A composes a message and send to user B, how can I just "push" that new message to that particular user B ?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAM3VocpM%2Bn1Xw0mhMf3iWbQD%2BjZ%2BGini5v5XjPXYipXjnLTJzg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thai Tran

unread,
Dec 29, 2013, 8:59:29 PM12/29/13
to django...@googlegroups.com
Yes, that was what I thought. But letting the user subscribe to a channel without any validation / authorization is a bit scary. That is why I wanna push the message based on the user session, not through a user name or strings like that

Mike Dewhirst

unread,
Dec 29, 2013, 9:27:15 PM12/29/13
to django...@googlegroups.com
On 30/12/2013 12:59pm, Thai Tran wrote:
> Yes, that was what I thought. But letting the user subscribe to a
> channel without any validation / authorization is a bit scary. That is
> why I wanna push the message based on the user session, not through a
> user name or strings like that

If timing requirements permit, you could let the client side request
messages frequently enough to satisfy users. I think that would be
nicely low-tech and somewhat tune-able.

>
> On 12/30/2013 2:03 AM, Nevio Vesic wrote:
>> Well You can always send custom events for some specific channel. Example:
>>
>> socket.on("global_event",function(channel,data){});
>> socket.on("user_XYZ",function(channel,data){});
>>
>> emit_to_channel('some_room', 'gobal_event', 'hello')
>> emit_to_channel('some_room', 'user_XYZ', 'hello XYZ')
>>
>> I understand this is not the most secure way but you can ensure
>> additional encryption like hashing on every request or shit like that
>> or even have every user connects to its own "secured" channel.
>>
>> Hope this helps.
>>
>>
>> Hi,
>>
>> I am working on a message sending/reading app atm. Is there any
>> way to push a message to a particular user session by using Redis
>> and SSE ? I am using the tutorial at
>> https://github.com/fcurella/django-push-demo and it works great
>> with the current setup (which means I can send the whole bunks of
>> new messages to all users but this is not what I wish for,
>> obviously). When a user A composes a message and send to user B,
>> how can I just "push" that new message to that particular user B ?
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users...@googlegroups.com
>> <mailto:django-users%2Bunsu...@googlegroups.com>.
>> To post to this group, send email to django...@googlegroups.com
>> <mailto:django...@googlegroups.com>.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAM3VocpM%2Bn1Xw0mhMf3iWbQD%2BjZ%2BGini5v5XjPXYipXjnLTJzg%40mail.gmail.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to django-users...@googlegroups.com.
>> To post to this group, send email to django...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAD1DFf1T0nTLPV2fO5Y4RDgmZ%3DWQziFCeORearNi1ioX43Zg5w%40mail.gmail.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/52C0D381.3060100%40gmail.com.
Reply all
Reply to author
Forward
0 new messages