【发布时间】:2020-05-07 03:26:40
【问题描述】:
中间件如何读取所有 websocket 消息?
据我了解,django-channel 中间件就像https://github.com/django/channels/blob/2a98606c1e0600cbae71ae1f02f31aae5d01f82d/channels/middleware.py。
async def coroutine_call(self, inner_instance, scope, receive, send):
"""
ASGI coroutine; where we can resolve items in the scope
(but you can't modify it at the top level here!)
"""
await inner_instance(receive, send)
我知道如果我调用await receive() 而不是await inner_instance(receive, send),我会收到一条 websocket 消息,但在这种情况下 websocket 处理程序将不再工作。
coroutine_call 怎样才能接收到 websocket 消息,同时将其转发到下一个 websocket 中间件或处理程序?
【问题讨论】:
标签: django websocket django-channels