Todos os exemplos

Exemplos

Como um app de chat entrega uma mensagem em tempo real

O upgrade para WebSocket mensagem por mensagem, uma mensagem repassada assim que chega e dois servidores de chat ligados por um message broker, para que amigos em servidores diferentes continuem conversando ao vivo.

Este vídeo foi feito com a habilidade Design de sistemas.

  • 1:11
  • Design de sistemas
  • Narrado por Orus
  • Inglês

Feito a partir de um prompt

How does a chat app deliver a message in real time? Show the WebSocket connection step by step.

Transcrição do vídeo

One message must reach your friend without either of you refreshing.

Your app contacts the server, requesting a WebSocket upgrade over HTTP one point one. Success returns status one hundred one.

WebSocket stays open, so either side can send immediately. Your friend's app establishes its own WebSocket connection.

You send a message, and the server forwards it immediately. Your friend's acknowledgement confirms delivery, not reading.

Your app and your friend's app share one server. In this example, a thousand messages per second makes it ninety-five percent busy.

Your friend reconnects to another server; a message broker now routes messages between their separate connections.

Why add a broker? It crosses server boundaries, but costs another network hop and operational complexity.

Apps keep WebSockets open, servers manage connections, and the broker routes live messages. Chat and multiplayer updates use this pattern.

Seu tema, desenhado em cerca de um minuto.

Seus primeiros 2 vídeos são grátis, de até 1 minuto cada, com marca d’água. Não precisa de cartão. Produto completo, com todas as vozes e estilos incluídos.