""" ASGI config for daren_project project. It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/ """ import os os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'daren_project.settings') from django.core.asgi import get_asgi_application from channels.routing import ProtocolTypeRouter, URLRouter from channels.auth import AuthMiddlewareStack # WebSocket 路由 django_asgi_app = get_asgi_application() from apps.chat.routing import websocket_urlpatterns as chat_websocket_urlpatterns # WebSocket 路由 from apps.notification.routing import websocket_urlpatterns as notification_websocket_urlpatterns # WebSocket 路由 application = ProtocolTypeRouter({ "http": django_asgi_app, "websocket": AuthMiddlewareStack( URLRouter( chat_websocket_urlpatterns + notification_websocket_urlpatterns ) ), })