Hi,
Newbie here. (please bear with me if this a stupid question)
I am going through the tutorial and doc and got this question regarding how ProtocolTypeRouter works.
ProtocolTypeRouter.__init__ takes a dict "application_mapping" and append a key-value pair to it: "http': class AsgiHandler
As doc says ASGI application is created on a per scope basis, I think I vaguely understand how the "http" one works.
Once a http scope comes in, an instance/object of class AsgiHandler is initiated, which lasts for the duration of the scope.
So it is one scope leads to one ASGI application/object
But I am confused about this one:
application = ProtocolTypeRouter({
# (http->django views is added by default)
'websocket': AuthMiddlewareStack(
URLRouter(
chat.routing.websocket_urlpatterns
)
),
})
The whole value of this key-value pair AuthMiddlewareStack(URLRouter(chat.routing.websocket_urlpatterns)) seems to be a object not a class,
so that means the application already exists before a websocket scope comes in. How does this conform to "one scope one application" rule?
Any help would be appreciated.
Thanks
Drew