-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4d17f7
commit 13a7628
Showing
6 changed files
with
80 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
# routing.py | ||
from django.urls import re_path | ||
from django.urls import path | ||
from . import consumers | ||
|
||
websocket_urlpatterns = [ | ||
re_path(r"ws/chats/(?P<chat_id>\d+)/$", consumers.ChatConsumer.as_asgi()), | ||
path("ws/chat/<int:chat_id>/", consumers.ChatConsumer.as_asgi()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,22 @@ | ||
# # """ | ||
# # ASGI config for core 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.0/howto/deployment/asgi/ | ||
# # """ | ||
|
||
# # import os | ||
|
||
# # from django.core.asgi import get_asgi_application | ||
|
||
# # os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") | ||
|
||
# # application = get_asgi_application() | ||
|
||
|
||
# import os | ||
# import django | ||
|
||
# django.setup() | ||
# from django.core.asgi import get_asgi_application | ||
# from channels.routing import ProtocolTypeRouter, URLRouter | ||
# from channels.auth import AuthMiddlewareStack | ||
# from apps.chats.consumers import ChatConsumer | ||
# from django.urls import re_path | ||
|
||
# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your_project_name.settings") | ||
|
||
# application = ProtocolTypeRouter( | ||
# { | ||
# "http": get_asgi_application(), | ||
# "websocket": AuthMiddlewareStack( | ||
# URLRouter( | ||
# [ | ||
# re_path(r"ws/chat/(?P<chat_id>\d+)/$", ChatConsumer.as_asgi()), | ||
# ] | ||
# ) | ||
# ), | ||
# } | ||
# ) | ||
|
||
|
||
# asgi.py | ||
import django | ||
|
||
django.setup() | ||
|
||
import os | ||
import environ | ||
|
||
from django.core.asgi import get_asgi_application | ||
from channels.routing import ProtocolTypeRouter, URLRouter | ||
from channels.auth import AuthMiddlewareStack | ||
from apps.chats import routing | ||
|
||
import environ | ||
|
||
env = environ.Env() | ||
env.read_env(".env") | ||
|
||
# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings') | ||
|
||
application = ProtocolTypeRouter( | ||
{ | ||
"http": get_asgi_application(), | ||
"websocket": AuthMiddlewareStack(URLRouter(routing.websocket_urlpatterns)), | ||
"websocket": URLRouter(routing.websocket_urlpatterns), | ||
} | ||
) |