When a user sends a message, the message is first sent to the server, which verifies the user’s identity and checks if the recipient is online. If the recipient is online, the server forwards the message to the recipient’s device in real-time. If the recipient is offline, the message is queued until the recipient comes online.