You don't have to send the messages all the way to the client (browser), you can handle them directly in the consumer still on the serverside. As far as I know you'll have to keep track of metadata like all users connections yourself, but you have the connect(), disconnect() method pair to put your tracking code into. On Mon, 2020-04-06 at 05:36 -0700, krnrrr wrote: > thank you for the help. > I need to try it out. i think it's more down the "tell-clients-to- > tell-me-to-close" route which i wanted to escape. > however, i still don't understand how i can get ALL connections of a > user knowing only his token. > > i mean, when i have an event in the system, i want to notify a user > about - i KNOW which group I must send it to, so it's up to client to > consume this message. I did all I should - sent it. And now it's like > vice versa - I must learn which group to send message to, knowing > only a recipient ID. > > I imagined it as like in django admin view there could be a page at > UserAdmin: "close all websockets for this user" - in such case we > have a manage.py command, or any random view which knows nothing > about clients-communicatiors. only about a user, whose connections > must be closed. > > maybe, you're right, and i'm thinking about it the wrong way.... > > On Monday, 6 April 2020 15:28:44 UTC+4, Roger Gammans wrote: > > I think you are looking at it from the wrong direction. > > Think about it in terms of consumers/connections, not in terms of > > users,and in terms of send receiving events. > > When in your consumers connect method, you subscribe > > (eg self.channel_layer.group_add() ) to add appropriate group to > > send user global messages. One of those messages is close. Then you > > just need to send the close message, and make sure you have code to > > close the connection at each subscriber. The group doesn't matter > > you had use any which doesn't conflict, you might even be able to > > use one of your exisiting groups. Although are they the Redis > > names? I would avoid delving under the hood with channel_layers and > > poking redis directly - unless your creating you own keys. > > > > -- > > 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 [email protected]. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/cb1b8bbc-dc9c-4cdc-a45c-9c30ed871cd8%40googlegroups.com > . >
-- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/16b7c749df844d13fd186daf69d91276a0cc451b.camel%40gammascience.co.uk.

