↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Build a Video Chat App in Phoenix LiveView

The article shows how to build a real-time video chat app in Phoenix LiveView. It starts with room creation and room lookup, then adds Phoenix Presence to track who is connected in each room. From there, it wires LiveView hooks and JavaScript to access the camera, create peer connections, and pass signaling data between clients through PubSub-backed LiveView events.

Reading notes
#

  • Creates a room model with title and slug, with a unique slug index and slug normalization.
  • Uses LiveView to create rooms and to show a room by slug, redirecting if the room does not exist.
  • Uses Phoenix Presence to track ephemeral connected users in a room topic.
  • Adds a local video stream through a LiveView hook and browser media access.
  • Explains WebRTC signaling, SDP offers and answers, ICE candidates, and STUN servers.
  • Uses a mesh architecture so each user creates a peer connection with every other connected user.
  • Sends offer requests, SDP offers, answers, and ICE candidates through LiveView events and PubSub broadcasts.
  • Uses hidden DOM elements with hooks to pass server-side state into JavaScript.
  • Adds a STUN server to the Phoenix application with a GenServer and starts it in the supervision tree.