28 lines
704 B
Python
28 lines
704 B
Python
import os
|
|
|
|
from django.core.asgi import get_asgi_application
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
|
|
|
|
asgi_application = get_asgi_application()
|
|
|
|
from channels.routing import ProtocolTypeRouter, URLRouter # noqa
|
|
from django.urls import re_path # noqa
|
|
|
|
from core.apps.chat.consumers import ChatConsumer # noqa
|
|
from core.apps.chat.middlewares.auth import JWTAuthMiddlewareStack # noqa
|
|
|
|
websocket_urlpatterns = [
|
|
re_path(
|
|
r"^ws/chat/room/(?P<room_id>\d+)/$",
|
|
ChatConsumer.as_asgi(),
|
|
),
|
|
]
|
|
|
|
application = ProtocolTypeRouter({
|
|
"http": asgi_application,
|
|
"websocket": JWTAuthMiddlewareStack(
|
|
URLRouter(websocket_urlpatterns)
|
|
),
|
|
})
|