SlideShare a Scribd company logo
1 of 16
Download to read offline
Build a Real-time, WebSockets-
enabled Chat in less than 5 minutes
with Ember-CLI and Python
Derek Edwards
August 4, 2015
About me
@derekbedwards

github.com/derekbedwards

linkedin.com/in/derekbedwards
Lean Startup, Ember.JS & Python evangelist
Co-founder / CTO of CoachLogix

Former co-founder Acclaimd, Hungerly
Prerequisites
• python / pip / virtualenv installed
• Ember-CLI + dependencies installed
• See http://www.ember-cli.com/
Overview
• Start a base Ember-CLI project as a chat client
• Install ember-websockets module
• Create a basic application controller and template
• Start a base Python Tornado project as a chat server
• Create a Python virtualenv and install Tornado
• Create a basic Python websocket server
• Run the Python websocket server and Ember CLI client
• Magic!
Create Ember project
mkdir chatdemo
cd chatdemo
ember init
ember install ember-websockets
ember g initializer websocket
ember g route application
ember g controller application
Setup Ember environment
Add a
contentSecurityPolicy
so we can talk to
WebSockets
Create a websocket initializer
Injects a ‘websockets’
object into all controllers
Setup main controller
Initializes websocket,
sets up handlers
Catches open event
on the websocket
Push received
messages into the
messages array
Constructs and sends
message to web
socket when user
presses send
Setup main template
Collect a name from
the user
Display all received
messages (or none)
Provide an entry field
for new messages
Display a Send button
tied to the
sendMessage action
Let’s see what we have so far
ember server
Ugly but does the job.
Browser is trying to
connect to WebSocket
endpoint
Setup python environment
virtualenv env
source env/bin/activate
pip install tornado
Create a simple server.py
Extend from Tornado
WebSocketHandler
When a new client
connects, add them to
a list of clients
When a message is
received, broadcast to
all registered clients
When a client
disconnects, remove
them from the list
Start the server
python server.py
Some raw data
Limitations / Improvements
• No authentication / user models
• Implement JWT or similar mechanism
• No chat history / archive
• Need some kind of persistent data store for message
backlog to be more ‘Slack-like’
• Fragile message distribution / queue
• Implement redis or better yet Amazon Simple Queue
Service
That’s all!
Thanks to Heather Brysiewicz + Erik Hanchett
Code from this talk:

github.com/derekbedwards/ember-python-chat
—
@derekbedwards
github.com/derekbedwards
linkedin.com/in/derekbedwards

More Related Content

What's hot

Real Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.ioReal Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.ioMindfire Solutions
 
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014Stéphane ESCANDELL
 
Using Websockets in Play !
Using Websockets in Play !Using Websockets in Play !
Using Websockets in Play !Knoldus Inc.
 
Using Websockets with Play!
Using Websockets with Play!Using Websockets with Play!
Using Websockets with Play!Andrew Conner
 
Real time web: is there a life without socket.io and node.js?
Real time web: is there a life without socket.io and node.js?Real time web: is there a life without socket.io and node.js?
Real time web: is there a life without socket.io and node.js?Eduard Trayan
 
Socket.io under the hood
Socket.io under the hoodSocket.io under the hood
Socket.io under the hoodHaokang Den
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDDSudar Muthu
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebPeter Lubbers
 
Websocket protocol overview
Websocket protocol overviewWebsocket protocol overview
Websocket protocol overviewallenmeng
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2Wyatt Fang
 
Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010sullis
 
Getting Started with HTML 5 Web workers
Getting Started with HTML 5 Web workersGetting Started with HTML 5 Web workers
Getting Started with HTML 5 Web workersFlumes
 

What's hot (19)

Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
Real Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.ioReal Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.io
 
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
 
Using Websockets in Play !
Using Websockets in Play !Using Websockets in Play !
Using Websockets in Play !
 
Using Websockets with Play!
Using Websockets with Play!Using Websockets with Play!
Using Websockets with Play!
 
Real time web: is there a life without socket.io and node.js?
Real time web: is there a life without socket.io and node.js?Real time web: is there a life without socket.io and node.js?
Real time web: is there a life without socket.io and node.js?
 
Socket.io under the hood
Socket.io under the hoodSocket.io under the hood
Socket.io under the hood
 
Socket.io
Socket.ioSocket.io
Socket.io
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the Web
 
Node.js
Node.jsNode.js
Node.js
 
JavaScript Web Workers
JavaScript Web WorkersJavaScript Web Workers
JavaScript Web Workers
 
Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
 
Ws
WsWs
Ws
 
Websocket protocol overview
Websocket protocol overviewWebsocket protocol overview
Websocket protocol overview
 
Web socket with php v2
Web socket with php v2Web socket with php v2
Web socket with php v2
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
 
Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010
 
Getting Started with HTML 5 Web workers
Getting Started with HTML 5 Web workersGetting Started with HTML 5 Web workers
Getting Started with HTML 5 Web workers
 

Similar to How to build a realtime, WebSockets-enabled chat in less than 5 minutes

Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Continuous Testing and New Tools for Automation - Presentation from StarWest ...Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Continuous Testing and New Tools for Automation - Presentation from StarWest ...Sauce Labs
 
Learn Advanced JAVA at ASIT
Learn Advanced JAVA at ASITLearn Advanced JAVA at ASIT
Learn Advanced JAVA at ASITASIT
 
Continuous Integration using Jenkins with Python
Continuous Integration using Jenkins with PythonContinuous Integration using Jenkins with Python
Continuous Integration using Jenkins with PythonInexture Solutions
 
E gov security_tut_session_4_lab
E gov security_tut_session_4_labE gov security_tut_session_4_lab
E gov security_tut_session_4_labMustafa Jarrar
 
A Byte of Software Deployment
A Byte of Software DeploymentA Byte of Software Deployment
A Byte of Software DeploymentGong Haibing
 
What is Node.js? (ICON UK)
What is Node.js? (ICON UK)What is Node.js? (ICON UK)
What is Node.js? (ICON UK)Tim Davis
 
.NET Cloud-Native Bootcamp
.NET Cloud-Native Bootcamp.NET Cloud-Native Bootcamp
.NET Cloud-Native BootcampVMware Tanzu
 
BeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruBeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruMichele Orru
 
Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009Matt Hamilton
 
Sa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administratorsSa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administratorsSharon James
 
React Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + AuthenticationReact Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + AuthenticationKobkrit Viriyayudhakorn
 
Using REST with VSTS and TFS
Using REST with VSTS and TFSUsing REST with VSTS and TFS
Using REST with VSTS and TFSJeff Bramwell
 
CloudShare Dev and Test SPSTCDC
CloudShare Dev and Test SPSTCDCCloudShare Dev and Test SPSTCDC
CloudShare Dev and Test SPSTCDCChris Riley ☁
 
Installing WordPress on AWS
Installing WordPress on AWSInstalling WordPress on AWS
Installing WordPress on AWSManish Jain
 
How to build webapps with tools
How to build webapps with toolsHow to build webapps with tools
How to build webapps with toolsPasindu Perera
 
Build your first Chatbot
Build your first ChatbotBuild your first Chatbot
Build your first ChatbotNadim GOUIA
 
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS FargateBuilding a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargatedatree
 
PyWBEM Rapid Overview
PyWBEM Rapid Overview PyWBEM Rapid Overview
PyWBEM Rapid Overview SNIATutorials
 
Simplified DevOps Bliss -with OpenAI API
Simplified DevOps Bliss -with OpenAI APISimplified DevOps Bliss -with OpenAI API
Simplified DevOps Bliss -with OpenAI APIVictorSzoltysek
 

Similar to How to build a realtime, WebSockets-enabled chat in less than 5 minutes (20)

Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Continuous Testing and New Tools for Automation - Presentation from StarWest ...Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Continuous Testing and New Tools for Automation - Presentation from StarWest ...
 
Learn Advanced JAVA at ASIT
Learn Advanced JAVA at ASITLearn Advanced JAVA at ASIT
Learn Advanced JAVA at ASIT
 
Continuous Integration using Jenkins with Python
Continuous Integration using Jenkins with PythonContinuous Integration using Jenkins with Python
Continuous Integration using Jenkins with Python
 
E gov security_tut_session_4_lab
E gov security_tut_session_4_labE gov security_tut_session_4_lab
E gov security_tut_session_4_lab
 
A Byte of Software Deployment
A Byte of Software DeploymentA Byte of Software Deployment
A Byte of Software Deployment
 
What is Node.js? (ICON UK)
What is Node.js? (ICON UK)What is Node.js? (ICON UK)
What is Node.js? (ICON UK)
 
.NET Cloud-Native Bootcamp
.NET Cloud-Native Bootcamp.NET Cloud-Native Bootcamp
.NET Cloud-Native Bootcamp
 
BeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruBeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-Orru
 
ServerSentEventsV2.pdf
ServerSentEventsV2.pdfServerSentEventsV2.pdf
ServerSentEventsV2.pdf
 
Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009
 
Sa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administratorsSa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administrators
 
React Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + AuthenticationReact Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + Authentication
 
Using REST with VSTS and TFS
Using REST with VSTS and TFSUsing REST with VSTS and TFS
Using REST with VSTS and TFS
 
CloudShare Dev and Test SPSTCDC
CloudShare Dev and Test SPSTCDCCloudShare Dev and Test SPSTCDC
CloudShare Dev and Test SPSTCDC
 
Installing WordPress on AWS
Installing WordPress on AWSInstalling WordPress on AWS
Installing WordPress on AWS
 
How to build webapps with tools
How to build webapps with toolsHow to build webapps with tools
How to build webapps with tools
 
Build your first Chatbot
Build your first ChatbotBuild your first Chatbot
Build your first Chatbot
 
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS FargateBuilding a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
 
PyWBEM Rapid Overview
PyWBEM Rapid Overview PyWBEM Rapid Overview
PyWBEM Rapid Overview
 
Simplified DevOps Bliss -with OpenAI API
Simplified DevOps Bliss -with OpenAI APISimplified DevOps Bliss -with OpenAI API
Simplified DevOps Bliss -with OpenAI API
 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 

Recently uploaded (20)

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 

How to build a realtime, WebSockets-enabled chat in less than 5 minutes

  • 1. Build a Real-time, WebSockets- enabled Chat in less than 5 minutes with Ember-CLI and Python Derek Edwards August 4, 2015
  • 2. About me @derekbedwards
 github.com/derekbedwards
 linkedin.com/in/derekbedwards Lean Startup, Ember.JS & Python evangelist Co-founder / CTO of CoachLogix
 Former co-founder Acclaimd, Hungerly
  • 3. Prerequisites • python / pip / virtualenv installed • Ember-CLI + dependencies installed • See http://www.ember-cli.com/
  • 4. Overview • Start a base Ember-CLI project as a chat client • Install ember-websockets module • Create a basic application controller and template • Start a base Python Tornado project as a chat server • Create a Python virtualenv and install Tornado • Create a basic Python websocket server • Run the Python websocket server and Ember CLI client • Magic!
  • 5. Create Ember project mkdir chatdemo cd chatdemo ember init ember install ember-websockets ember g initializer websocket ember g route application ember g controller application
  • 6. Setup Ember environment Add a contentSecurityPolicy so we can talk to WebSockets
  • 7. Create a websocket initializer Injects a ‘websockets’ object into all controllers
  • 8. Setup main controller Initializes websocket, sets up handlers Catches open event on the websocket Push received messages into the messages array Constructs and sends message to web socket when user presses send
  • 9. Setup main template Collect a name from the user Display all received messages (or none) Provide an entry field for new messages Display a Send button tied to the sendMessage action
  • 10. Let’s see what we have so far ember server Ugly but does the job. Browser is trying to connect to WebSocket endpoint
  • 11. Setup python environment virtualenv env source env/bin/activate pip install tornado
  • 12. Create a simple server.py Extend from Tornado WebSocketHandler When a new client connects, add them to a list of clients When a message is received, broadcast to all registered clients When a client disconnects, remove them from the list
  • 15. Limitations / Improvements • No authentication / user models • Implement JWT or similar mechanism • No chat history / archive • Need some kind of persistent data store for message backlog to be more ‘Slack-like’ • Fragile message distribution / queue • Implement redis or better yet Amazon Simple Queue Service
  • 16. That’s all! Thanks to Heather Brysiewicz + Erik Hanchett Code from this talk:
 github.com/derekbedwards/ember-python-chat — @derekbedwards github.com/derekbedwards linkedin.com/in/derekbedwards