From be127611e5df506f1b448c7ba5b311de10308273 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 6 Jul 2016 11:55:45 -0700 Subject: [PATCH] Implement default websocket.connect consumer. --- channels/routing.py | 10 ++++++++++ setup.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/channels/routing.py b/channels/routing.py index 83108ba..a5593a6 100644 --- a/channels/routing.py +++ b/channels/routing.py @@ -53,6 +53,10 @@ class Router(object): # called once, thankfully. from .handler import ViewConsumer self.add_route(Route("http.request", http_consumer or ViewConsumer())) + # We also add a no-op websocket.connect consumer to the bottom, as the + # spec requires that this is consumed, but Channels does not. Any user + # consumer will override this one. + self.add_route(Route("websocket.connect", null_consumer)) @classmethod def resolve_routing(cls, routing): @@ -239,6 +243,12 @@ class Include(object): return result +def null_consumer(*args, **kwargs): + """ + Standard no-op consumer. + """ + + # Lowercase standard to match urls.py route = Route route_class = RouteClass diff --git a/setup.py b/setup.py index a982fb6..6f3f0f6 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,6 @@ setup( install_requires=[ 'Django>=1.8', 'asgiref>=0.13', - 'daphne>=0.13', + 'daphne>=0.14', ] )