Chat advance
This commit is contained in:
parent
8bce7d33ca
commit
b12c03074a
0
chat/__init__.py
Normal file
0
chat/__init__.py
Normal file
3
chat/admin.py
Normal file
3
chat/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
6
chat/apps.py
Normal file
6
chat/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ChatConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'chat'
|
3
chat/models.py
Normal file
3
chat/models.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
3
chat/tests.py
Normal file
3
chat/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
chat/views.py
Normal file
3
chat/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
@ -14,7 +14,7 @@ export default class extends AbstractView {
|
||||
if (data.type === 'chat') {
|
||||
let messages = document.getElementById('messages')
|
||||
|
||||
let username = data.username === null ? "NoName" : data.username;
|
||||
let username = data.username === null || data.username.length <= 0 ? "NoName" : data.username;
|
||||
messages.insertAdjacentHTML('beforeend', `
|
||||
<div><p>${username}: ${data.message}</p></div>
|
||||
`)
|
||||
|
@ -10,7 +10,7 @@ https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
|
||||
import os
|
||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||
from channels.auth import AuthMiddlewareStack
|
||||
import frontend.routing
|
||||
import chat.routing
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
@ -20,7 +20,7 @@ application = ProtocolTypeRouter({
|
||||
'http':get_asgi_application(),
|
||||
'websocket':AuthMiddlewareStack(
|
||||
URLRouter(
|
||||
frontend.routing.websocket_urlpatterns
|
||||
chat.routing.websocket_urlpatterns
|
||||
)
|
||||
)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user