diff --git a/smoothschedule/config/asgi.py b/smoothschedule/config/asgi.py new file mode 100644 index 0000000..8785626 --- /dev/null +++ b/smoothschedule/config/asgi.py @@ -0,0 +1,26 @@ +import os + +from django.core.asgi import get_asgi_application + +# Fetch Django's ASGI application early to ensure the AppRegistry is populated +# before importing code that may import ORM models. +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") # Use local settings for ASGI +django_asgi_app = get_asgi_application() + +from channels.auth import AuthMiddlewareStack +from channels.routing import ProtocolTypeRouter, URLRouter + +from smoothschedule.tickets import routing as tickets_routing # Assuming we'll have tickets routing + + +application = ProtocolTypeRouter( + { + "http": django_asgi_app, + # Just HTTP for now. (We can add other protocols later.) + "websocket": AuthMiddlewareStack( + URLRouter( + tickets_routing.websocket_urlpatterns # Include ticket-specific WebSocket routes + ) + ), + } +) \ No newline at end of file