Skip to content

Commit

Permalink
fixes issues
Browse files Browse the repository at this point in the history
  • Loading branch information
walosha committed Jan 30, 2023
1 parent ac1fdc7 commit 17a381e
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 2 deletions.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions church/channel/apps.py → church/chat/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.apps import AppConfig


class ChannelConfig(AppConfig):
class ChatConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'channel'
name = 'chat'
18 changes: 18 additions & 0 deletions church/chat/consumers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import json
from channels.generic.websocket import WebsocketConsumer
class ChatConsumer(WebsocketConsumer):
def connect(self):
# accept connection
self.accept()


def disconnect(self, close_code):
pass


# receive message from WebSocket
def receive(self, text_data):
text_data_json = json.loads(text_data)
message = text_data_json['message']
# send message to WebSocket
self.send(text_data=json.dumps({'message': message}))
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions church/chat/routing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import re_path
from . import consumers



websocket_urlpatterns = [
re_path(r'ws/chat/room/(?P<course_id>\d+)/$',
consumers.ChatConsumer.as_asgi()),
]
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions church/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'rest_framework.authtoken',
'rest_framework_simplejwt.token_blacklist',
'import_export',
"chat",
'channels',
'django_filters',
'taggit',
Expand Down
1 change: 1 addition & 0 deletions church/daphne.sock.lock

0 comments on commit 17a381e

Please sign in to comment.