Creating a full Chat
A very popular exercise when implementing WebSockets in any technology is to create a simple Chat. However, the difficulty increases considerably when we have several connected clients who are going to talk in private spaces and open groups so that any client can read or participate. Using Channels, we are creating a solid enough abstraction so that we can focus on other issues.
Let’s create a Chat complete with modern features:
- Message history
- Private conversations
- Groups
- Customers associated with a registered user in the database
Next, we must define the database. We will define the models for users, rooms, and messages. That way, we will be able to store the actions of each user and there will be a record of everything that happens.
Defining the database
In this section, we are going to create some models in the database to manage customers, groups (which we will call rooms), and messages.
Edit /app/chat/models...