Added WebSocket routes for the live_chat app, ensuring chat WebSockets are handled correctly by adding live_chat.routing.websocket_urlpatterns.
Settings (settings.py):
Added live_chat to INSTALLED_APPS for managing chat functionality.
URL Routing (urls.py):
Added a new API route for chat: /api/chat/, connecting chat views and WebSocket routing to the application.
Live Chat App:
Models (models.py):
Message: Handles chat messages with fields for sender, receiver, timestamp, and content.
Relationship: Manages friend requests and chat relationships between users.
Admin (admin.py): Registered Message and Relationship models.
Views (views.py):
Added views to manage relationships between users (RelationshipStatusView).
API endpoints for retrieving and updating relationship status between two users.
WebSocket (consumers.py):
Implemented ChatConsumer to manage WebSocket connections, sending and receiving messages, and updating the frontend dynamically.
Routing (routing.py): Defined WebSocket URL patterns for live chat.
Django Admin:
Registered Message and Relationship models for Django admin interface.
New User Management API (views.py in usermanagement):
Added endpoint /users// to retrieve a user’s ID by their display name, used for user search input.
Frontend Changes:
New Live Chat Interface (live_chat.html):
HTML Structure: A responsive chat interface with a chat window, user search field, user list, and message display area.
CSS Styling: Defined styles for chat messages, including separate styles for sent (.message-sender) and received (.message-receiver) messages, and timestamp styling.
Frontend JavaScript (live-chat.js and chatHandler.js):
WebSocket Initialization: Dynamically sets up a WebSocket connection when the chat page is loaded.
Real-Time Updates: Handles real-time message sending, receiving, and updating the chat interface with the latest info.
User Management: Includes a dynamic user list and allows users to send friend requests, accept, or block requests in real-time + manage game invitations with befriended users + user blocking mechanism to hide your online status from blocked user's active user list and block all of their messages
Chat and game notifications across all pages (except unregistered paths and /game)
Chat Room (chat_room.html):
Introduced a separate chat room page with message history, input handling, and dynamic user interaction through WebSockets.
Frontend Routing (app.js and router.js):
Added routes for the new chat and chat room pages.
Integrated chat-specific logic into the existing frontend router, ensuring chat functionality is properly initialized.
CSS Changes:
Chat-Specific Styles (chat.css): Added styles for the chat interface, including the chat window, message items, and user list layout.
Backend Changes:
ASGI Configuration (asgi.py):
Settings (settings.py):
URL Routing (urls.py):
Live Chat App:
Django Admin:
New User Management API (views.py in usermanagement):
Frontend Changes:
New Live Chat Interface (live_chat.html):
Frontend JavaScript (live-chat.js and chatHandler.js):
Chat Room (chat_room.html):
Frontend Routing (app.js and router.js):
CSS Changes: