Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What's the fuss about Phoenix?

What's the fuss about Phoenix?

WebCamp Zagreb, 2016

Saša Jurić

October 31, 2016
Tweet

More Decks by Saša Jurić

Other Decks in Programming

Transcript

  1. Erlang is a programming language used to build massively scalable

    soft real-time systems with requirements on high availability. erlang.org
  2. separate execution no shared memory separate garbage collection cooperation through

    communication isolated crashes detectable crashes of other processes
  3. client server join "lobby" send "room:42", "message", payload send "room:42",

    "message", payload socket send “lobby", "rooms", payload join "room:42"
  4. import Socket from "phoenix" socket = new Socket("/socket") socket.connect() room

    = socket.channel("room:elixir", payload) room.join()
  5. defmodule MySocket do use Phoenix.Socket transport :websocket, Phoenix.Transports.WebSocket transport :longpoll,

    Phoenix.Transports.LongPoll channel "lobby", LobbyChannel channel "room:*", RoomChannel # ... end
  6. defmodule RoomChannel do use Phoenix.Channel def join(topic, payload, socket) do

    # ... end def handle_in(event, payload, socket) do # ... end def handle_info(erlang_message, socket) do # ... end end
  7. defmodule RoomChannel do # ... def handle_in(event, payload, socket) do

    broadcast(socket, event, payload) # ... end # ... end