Friday, January 29, 2021

Django Channels:Detect whether disconnect() was done client or server?


Hello!
I need to detect whether connection was closed by server or client.How to do it?

disconnect() gets called when client disconnects or server disconnects (using self.close() or by not accept()-ing during connect() ).So I need to detect who caused the disconnect and take action based on that.I tried using custom close codes too.
But if the server disconnects using self.close() or client disconnects abnormally ,then I always get the close_code as 1006.So I cant detect caused the disconnect.
Is there way to do it?

Here's the link to the question in SO with code example.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1673a71e-a4dc-4063-a232-332d428e3db8n%40googlegroups.com.

No comments:

Post a Comment