build your own real-time web service with elixir phoenix
TRANSCRIPT
![Page 1: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/1.jpg)
ELIXIR/PHOENIXBUILD YOUR OWN REAL-TIME WEB SERVICE WITH
![Page 2: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/2.jpg)
PRESENTED BY: CHI-CHI EKWEOZOR AT:
MANCHESTER LAMBDA LOUNGE MON 17 OCT 2016
![Page 3: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/3.jpg)
TODAY’S WEB:
Hundreds of millions of interconnected services continuously exchanging data.
Reliability, concurrency, fault-tolerance, scalability, all expected as the norm.
![Page 4: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/4.jpg)
WHY ELIXIR? WHY PHOENIX?
BUILDING REAL-TIME WEB SERVICES
![Page 5: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/5.jpg)
ABOUT ME:
▸ Chi-chi Ekweozor (@thisischichi):
▸ Contract Software engineer - C/C++, PHP, JavaScript, and now Elixir
▸ Previously a social media marketing consultant!
▸ Combined social media know how with Elixir/Phoenix to create Assenty, a real-time Question & Answer tool for event organisers.
![Page 6: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/6.jpg)
INTENDED AUDIENCE:
This talk is intended for web developers with some familiarity with functional programming concepts.
It is a high level overview of the Phoenix web framework which is written in Elixir, a relatively new functional programming language.
No prior experience with Elixir is required.
![Page 7: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/7.jpg)
WE’LL COVER:
▸ Why Elixir?
▸ What is Phoenix?
▸ What are Phoenix Channels?
▸ How do they work?
▸ Assenty Live Demo: Phoenix Channels in Production
![Page 8: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/8.jpg)
IS IT FUNCTIONAL?WHY ELIXIR?
![Page 9: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/9.jpg)
ELIXIR IS A DYNAMIC, FUNCTIONAL LANGUAGE DESIGNED FOR BUILDING …
elixir-lang.org
![Page 11: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/11.jpg)
ELIXIR LEVERAGES THE ERLANG VM, KNOWN FOR RUNNING LOW-LATENCY,
elixir-lang.org
![Page 12: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/12.jpg)
DISTRIBUTED AND FAULT-TOLERANT SYSTEMS, WHILE ALSO BEING SUCCESSFULLY
elixir-lang.org
![Page 14: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/14.jpg)
![Page 15: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/15.jpg)
ELIXIR’S STRENGTHS:
![Page 16: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/16.jpg)
WHY ELIXIR?
▸ An extensible and well-documented dynamic language with Ruby-inspired syntax, undergirded by Erlang’s 30 year old, tried and tested virtual machine known as BEAM
▸ In-built pattern matching and the pipe operator |> makes it easy to work with and reason about immutable data
▸ Mix: an impressive tooling ecosystem that adds rock solid libraries for authentication, metrics, crypto, embedded systems support and much more
![Page 17: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/17.jpg)
RATIONALE FOR CREATING ELIXIR:
![Page 18: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/18.jpg)
“WHEN DESIGNING THE ERLANG LANGUAGE AND THE ERLANG VM,
José Valim, creator, Elixir
![Page 19: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/19.jpg)
JOE, MIKE AND ROBERT DID NOT AIM TO IMPLEMENT A FUNCTIONAL PROGRAMMING LANGUAGE,
José Valim, creator, Elixir
![Page 20: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/20.jpg)
THEY WANTED A RUNTIME WHERE THEY COULD BUILD DISTRIBUTED, FAULT-TOLERANT APPLICATIONS.
José Valim, creator, Elixir
![Page 21: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/21.jpg)
IT JUST HAPPENED THAT THE FOUNDATION FOR WRITING SUCH SYSTEMS SHARE MANY OF THE FUNCTIONAL
José Valim, creator, Elixir
![Page 22: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/22.jpg)
PROGRAMMING PRINCIPLES. AND IT REFLECTS IN BOTH ERLANG AND ELIXIR.
José Valim, creator, Elixir
![Page 23: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/23.jpg)
BENEFIT OF CODING IN ELIXIR:
![Page 24: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/24.jpg)
AT LEAST TWO THINGS YOU STAND TO GAIN WITH ELIXIR:
▸ Because of data immutability, concurrency is a lot easier to understand, and use:
▸ Your application or program will use all available cores on your machine to function. It just does.
▸ A single function definition lets you define different implementations depending on its arguments:
▸ Your application or program will be easier to modularise and test.
![Page 25: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/25.jpg)
WE’LL COVER:
▸ Why Elixir?
▸ What is Phoenix?
▸ What are Phoenix Channels?
▸ How do they work?
▸ Assenty Live Demo: Phoenix Channels in Production
![Page 26: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/26.jpg)
IS IT REAL-TIME?AND THIS PHOENIX?
![Page 27: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/27.jpg)
INTRODUCING PHOENIX:
▸ Phoenix is a web development framework written in Elixir which implements the server-side MVC pattern.
▸ Many of its components and concepts will seem familiar to those of us with experience in other web frameworks like Ruby on Rails or Python's Django.
▸ Phoenix is made up of a number of distinct parts, each with its own purpose and role to play in building a web application.
Excerpted from the Phoenix Framework Guides
![Page 28: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/28.jpg)
ENDPOINTPHOENIX FRAMEWORK COMPONENT:
![Page 29: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/29.jpg)
HANDLES ALL ASPECTS OF REQUESTS UP UNTIL THE POINT WHERE THE ROUTER TAKES OVER
![Page 30: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/30.jpg)
ROUTERPHOENIX FRAMEWORK COMPONENT:
![Page 31: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/31.jpg)
PARSES INCOMING REQUESTS AND DISPATCHES THEM TO THE CORRECT CONTROLLER/ACTION, PASSING PARAMETERS AS NEEDED
![Page 32: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/32.jpg)
MODELSPHOENIX FRAMEWORK COMPONENT:
![Page 33: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/33.jpg)
USES ECTO, AN ELIXIR FRAMEWORK FOR PERSISTENCE TO READ AND PERSIST DATA TO AN UNDERLYING DATABASE
![Page 34: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/34.jpg)
CONTROLLERSPHOENIX FRAMEWORK COMPONENT:
![Page 35: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/35.jpg)
PROVIDE FUNCTIONS, CALLED ACTIONS, TO HANDLE REQUESTS
![Page 36: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/36.jpg)
VIEWSPHOENIX FRAMEWORK COMPONENT:
![Page 37: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/37.jpg)
RENDER TEMPLATES AND ACT AS A PRESENTATION LAYER
![Page 38: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/38.jpg)
TEMPLATESPHOENIX FRAMEWORK COMPONENT:
![Page 39: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/39.jpg)
HTML FILES INTO WHICH WE PASS DATA TO FORM COMPLETE HTTP RESPONSES
![Page 40: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/40.jpg)
CHANNELSPHOENIX FRAMEWORK COMPONENT:
![Page 41: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/41.jpg)
MANAGE (WEB) SOCKETS FOR EASY REAL-TIME COMMUNICATION
![Page 42: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/42.jpg)
PUBSUBPHOENIX FRAMEWORK COMPONENT:
![Page 43: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/43.jpg)
UNDERGIRDS THE CHANNEL LAYER AND ALLOWS CLIENTS TO SUBSCRIBE TO TOPICS
![Page 44: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/44.jpg)
WE’LL COVER:
▸ Why Elixir?
▸ What is Phoenix?
▸ What are Phoenix Channels?
▸ How do they work?
▸ Assenty Live Demo: Phoenix Channels in Production
![Page 45: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/45.jpg)
![Page 46: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/46.jpg)
WHAT ARE PHOENIX CHANNELS?
▸ Channels are a really exciting and powerful part of Phoenix that allow us to easily add soft real-time features to our applications.
▸ Channels are based on a simple idea - sending and receiving messages. Senders broadcast messages about topics.
▸ Receivers subscribe to topics so that they can get those messages. Senders and receivers can switch roles on the same topic at any time.
Excerpted from the Phoenix Framework Guides
![Page 47: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/47.jpg)
CHARACTERISTICS OF SOFT REAL-TIME SYSTEMS:
▸ You don’t have to hit every deadline, as opposed to the case in hard real-time systems.
▸ Performance will degrade if too many are missed but results are still valid after the deadline.
▸ Examples: airline reservation systems.
▸ Contrast with hard real-time systems where you must absolutely hit every deadline. Examples: nuclear systems, aircraft control systems, defence applications.
![Page 48: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/48.jpg)
TRADITIONAL STATELESS REQUEST-RESPONSE MODEL:Image taken from Programming Phoenix by Chris McCord, Bruce Tate, and José Valim
![Page 49: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/49.jpg)
PHOENIX CHANNELS GIVE YOU STATEFUL CONVERSATIONS:Image taken from Programming Phoenix by Chris McCord, Bruce Tate, and José Valim
![Page 50: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/50.jpg)
A SINGLE CLIENT ON A PAGE CONNECTS DIRECTLY WITH A PROCESS ON THE SERVER…
Chris McCord, Phoenix creator
![Page 51: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/51.jpg)
CALLED A CHANNEL.
Chris McCord, Phoenix creator
![Page 52: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/52.jpg)
SINCE ELIXIR CAN SCALE TO MILLIONS OF SIMULTANEOUS PROCESSES THAT MANAGE
Chris McCord, Phoenix creator
![Page 53: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/53.jpg)
MILLIONS OF CONCURRENT CONNECTIONS, YOU DO NOT HAVE TO RESORT TO THE …
Chris McCord, Phoenix creator
![Page 54: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/54.jpg)
REQUEST/RESPONSE MODEL TO MAKE THINGS EASY TO SCALE OR EVEN MANAGE.
Chris McCord, Phoenix creator
![Page 55: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/55.jpg)
A CLIENT CONNECTS TO A CHANNEL AND THEN SENDS AND RECEIVES MESSAGES.
Chris McCord, Phoenix creator
![Page 56: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/56.jpg)
THAT’S IT.
Chris McCord, Phoenix creator
![Page 57: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/57.jpg)
WHAT PHOENIX CHANNELS MAKE POSSIBLE:
▸ With Channels, neither senders nor receivers have to be Elixir processes.
▸ They can be anything that we can teach to communicate over a Channel - a JavaScript client, an iOS app, another Phoenix application, our watch.
▸ Whereas request/response interactions are stateless, conversations in a long-running process can be stateful.
Excerpted from the Phoenix Framework Guides
![Page 58: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/58.jpg)
WE’LL COVER:
▸ Why Elixir?
▸ What is Phoenix?
▸ What are Phoenix channels?
▸ How do they work?
▸ Assenty Live Demo: Phoenix Channels in Production
![Page 59: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/59.jpg)
WHAT’S INSIDE?UNDERSTANDING PHOENIX CHANNELS
![Page 60: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/60.jpg)
![Page 61: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/61.jpg)
HOW DO PHOENIX CHANNELS WORK?
▸ A Phoenix channel is a conversation.
▸ The channel sends messages, receives messages, and keeps state. We call the messages events.
▸ A Phoenix conversation is about a topic, and it maps onto application concepts like a chat room, a game, or in Assenty's case, the question board for an event.
Excerpted from Programming Phoenix by Chris McCord, Bruce Tate, and José Valim
![Page 62: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/62.jpg)
BENEFIT OF USING PHOENIX CHANNELS:
▸ For sophisticated user interactions like interactive pages or multiplayer games, you don’t have to work so hard to keep track of the conversation by using cookies, databases, or the like.
▸ Each call to a channel simply picks up where the last one left off.
▸ A client establishes a new connection with a web socket. That socket is transformed through the life of the conversation with the server.
Excerpted from Programming Phoenix by Chris McCord, Bruce Tate, and José Valim
![Page 63: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/63.jpg)
COMPONENTS OF A PHOENIX CHANNEL:
![Page 64: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/64.jpg)
![Page 65: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/65.jpg)
USER SOCKETPHOENIX CHANNEL COMPONENT:
![Page 66: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/66.jpg)
THIS MODULE SERVES AS THE STARTING POINT FOR ALL SOCKET CONNECTIONS
![Page 67: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/67.jpg)
RESPONSIBLE FOR AUTHENTICATING, IT ALSO DEFINES THE TRANSPORT
![Page 68: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/68.jpg)
LAYERS THAT WILL HANDLE THE CONNECTION BETWEEN THE CLIENT AND THE SERVER.
![Page 69: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/69.jpg)
TOPICPHOENIX CHANNEL COMPONENT:
![Page 70: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/70.jpg)
JUST AS A CONTROLLER PASSES AN ID PARAMETER TO REPRESENT A RESOURCE
![Page 71: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/71.jpg)
FOR A CONTROLLER, WE USE A TOPIC ID TO SCOPE A CHANNEL CONNECTION.
![Page 72: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/72.jpg)
WHEN CLIENTS JOIN A CHANNEL, THEY MUST PROVIDE A TOPIC. CLIENTS CAN JOIN
![Page 73: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/73.jpg)
ANY NUMBER OF CHANNELS AND ANY NUMBER OF TOPICS ON A CHANNEL.
![Page 74: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/74.jpg)
CHANNELPHOENIX CHANNEL COMPONENT:
![Page 75: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/75.jpg)
THIS MODULE ALLOWS CONNECTIONS AND LETS USERS DISCONNECT AND SEND EVENTS
![Page 76: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/76.jpg)
IT SUPPORTS 4 CALLBACKS: JOIN(), HANDLE_IN(), HANDLE_OUT(), HANDLE_INFO()
![Page 77: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/77.jpg)
1. JOIN(): CLIENTS JOIN TOPICS ON A CHANNEL
![Page 78: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/78.jpg)
2. HANDLE_IN(): RECEIVES DIRECT CHANNEL EVENTS
![Page 79: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/79.jpg)
3. HANDLE_OUT(): INTERCEPTS BROADCAST EVENTS
![Page 80: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/80.jpg)
4. HANDLE_INFO(): RECEIVES PLATFORM (OTP) MESSAGES
![Page 81: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/81.jpg)
CLIENT LIBRARYPHOENIX CHANNEL COMPONENT:
![Page 82: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/82.jpg)
A CONSTRUCT THAT CAN CONNECT DIRECTLY TO THE SERVER
![Page 83: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/83.jpg)
PHOENIX CURRENTLY SHIPS WITH ITS OWN JAVASCRIPT CLIENT.
![Page 84: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/84.jpg)
IOS, ANDROID, AND C# CLIENTS HAVE BEEN RELEASED WITH PHOENIX 1.0.
![Page 85: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/85.jpg)
YOUR CLIENT CODEPHOENIX CHANNEL COMPONENT:
![Page 86: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/86.jpg)
THIS JAVASCRIPT OBJECT ADDS REAL-TIME FUNCTIONALITY TO YOUR APPLICATION BY LISTENING FOR EVENTS GENERATED BY THE CALLBACKS (JOIN(), HANDLE_* ETC) DEFINED IN ELIXIR AND RESPONDING APPROPRIATELY.
![Page 87: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/87.jpg)
WE’LL COVER:
▸ Why Elixir?
▸ What is Phoenix?
▸ What are Phoenix channels?
▸ How do they work?
▸ Assenty Live Demo: Phoenix Channels in Production
![Page 88: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/88.jpg)
WHAT IS ASSENTY?
▸ Assenty is a real-time question and answer tool for event organisers.
▸ Written in Elixir, and running on the Phoenix framework, it provides a platform for capturing and persisting questions posted to an event’s ‘question board’
▸ A question board is an online archive of questions and answers discussed at a physical or virtual event.
▸ As each question and answer submitted to a question board is persisted to the database, it is easily shared via social media.
![Page 89: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/89.jpg)
PHOENIX CHANNELS LIVE DEMO:
▸ Visit the Question Board created during the live demo
▸ Thank you to all the participants!
![Page 90: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/90.jpg)
THE ENDTHAT’S ALL FOLKS!
![Page 91: Build Your Own Real-Time Web Service with Elixir Phoenix](https://reader034.vdocuments.net/reader034/viewer/2022052418/587071c81a28ab48378b7b1b/html5/thumbnails/91.jpg)
REFERENCES & RESOURCES
▸ Elixir website http://elixir-lang.org/
▸ On Functional Elixir http://blog.plataformatec.com.br/2016/05/beyond-functional-programming-with-elixir-and-erlang/
▸ Elixir Guides http://elixir-lang.org/getting-started/introduction.html
▸ Phoenix Overview http://www.phoenixframework.org/docs/overview
▸ Erlang and Functional Programming link