mirror of
https://github.com/django/daphne.git
synced 2025-04-20 08:42:18 +03:00
Fixed #244: .close() on Websocket generic consumers
This commit is contained in:
parent
27d064328a
commit
af606ff895
|
@ -106,6 +106,12 @@ class WebsocketConsumer(BaseConsumer):
|
|||
else:
|
||||
raise ValueError("You must pass text or bytes")
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Closes the WebSocket from the server end
|
||||
"""
|
||||
self.message.reply_channel.send({"close": True})
|
||||
|
||||
def raw_disconnect(self, message, **kwargs):
|
||||
"""
|
||||
Called when a WebSocket connection is closed. Base level so you don't
|
||||
|
|
|
@ -172,6 +172,9 @@ Note that this subclass still can't intercept ``Group.send()`` calls to make
|
|||
them into JSON automatically, but it does provide ``self.group_send(name, content)``
|
||||
that will do this for you if you call it explicitly.
|
||||
|
||||
``self.close()`` is also provided to easily close the WebSocket from the server
|
||||
end once you are done with it.
|
||||
|
||||
Sessions and Users
|
||||
------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user