SlideShare a Scribd company logo
1 of 45
AD117
WebSockets - "Pushing" the web forward
Mark Roden
PSC Group LLC
Principal Architect
About Marky
Over 18 years IBM Notes Domino® work
Principal Architect at PSC Group
• XPages Developer
• Project Leader
• Architect
Contact Information
– Blog: http://www.xomino.com
– Email: marky@xomino.com
– Twitter: @markyroden
– Skype: marky.roden
– "Come work for us - it will be fun"
www.psclistens.com @pscgroup
WebSockets
• What are WebSockets ?
• What does that even mean ?
• Why do I care ?
• Can I use WebSockets ?
• When can I use WebSockets
– Use Cases
– Web Servers
• Socket.io
• Demonstrations
WebSockets
• What are WebSockets?
• Bi-directional communication over the Web: Both the server and
client can send data at any time, or even at the same time. Only
the data itself is sent, without the overhead of HTTP headers,
dramatically reducing bandwidth
– HTML5Rocks.com
WebSockets
What does that even mean?
WebSockets
• What does that even mean?
– Evolution in browser to server communication
– Maximize efficiency in network
– Minimize latency
WebSockets
• What does that even mean?
– HTTP Overhead – 803 Bytes
WebSockets
• What does that even mean?
– WebSockets = no HTTP Headers – 86 Bytes
WebSockets
• What does that even mean?
– Before WebSockets - polling
• Has anything changed?
– No
• Has anything changed?
– Seriously dude, stop asking you are wasting bandwidth
• Has anything changed?
– Man, you people are impatient
• Has anything changed?
– No
• Has anything changed?
– Sure, let’s go with yes. Hang on while I get that for you.....
WebSockets
• What does that even mean?
– Before WebSockets
• Click button to perform server side task.....
– Waiting
– Waiting
– Waiting
– Go get a coffee
– Server timed out
– Repeat....
WebSockets
• What does that even mean?
– Using WebSockets – Real-Time Update
• Hey Server can you do this job for me and let me know when it is
done?
– Sure
• OK, time to be productive
• ..........some time later
– Hey Marky here is your answer........
WebSockets
• What does that even mean?
– Be nice to your users
– They don’t *want* to call the help desk......
WebSockets
Why should I care about WebSockets ?
WebSockets
• Why should I care about WebSockets ?
– W3C Defined JavaScript API
– Originally proposed as part of HTML5
– IETF-defined Protocol: RFC 6455
– Cross-Domain
– Secure
WebSockets
• Websockets vs REST
– http://blog.arungupta.me/rest-vs-websocket-comparison-
benchmarks/
• Arun Gupta – Java Champion
WebSockets
When can I use WebSockets ?
WebSockets
• When can I use WebSockets ?
– Standard in modern browsers (Aug 2015)
• http://caniuse.com/#feat=websockets
Windows Internet Explorer 9 - March 14, 2011
WebSockets
WebSockets Use Cases?
WebSockets
• WebSockets Use cases
– Instant notification of events
• Web Chat
• New items requiring action
• General notification
• Rapidly changing data
– Optimization
• Lower bandwith
• Lower memory usage
• Control of when a user receives the information
• Notification regardless of where the user is (within the domain)
WebSockets
• Websockets Use cases
– Better user experience
– Chat rooms
– Data refresh without polling
– Workflow event notification
– Social Feeds
– Location based applications
– Sports updates
WebSockets
So why aren’t we all using WebSockets already?
WebSockets
• So why aren’t we all using WebSockets ?
– Internet Explorer 9
– Search Engine Optimization
– HTTP has many good points
• Caching, routing, multiplexing, gzipping and lot more.
– Firewalls understand HTTP
WebSockets
WebSockets Servers
WebSockets
• WebSockets Servers
– Jave EE 7 servers
• WebSphere
• jBoss
• Jetty
• jWebSocket
– Tomcat
WebSockets
• WebSockets Servers
– Domino – via jWebSockets OSGI plugin
• http://www.openntf.org/main.nsf/project.xsp?r=project/w
ebshell-xpages-ext-lib
• http://xomino.com/2014/05/15/websockets-comes-to-
xpages-awesome-awesome-awesome/
WebSockets
• WebSockets Servers
– Node.js
• http://Socket.io
• JavaScript on the server
• JavaScript on the client
WebSockets
Socket.io
http://socket.io
WebSockets
• Socket.io setup
– Server side
• Install Node.js server
• npm install --save express
• npm install --save socket.io
– Client side
• <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
WebSockets
• Socket.io
– Send message to everyone connected
– Send messages to namespaced web pages
– Send group messages to users in a “room”
– Send targeted individual messages
– Users can be on any domain, but must be connected to the same
WebSockets server
WebSockets
• Socket.io
– Send message to everyone (server side code)
// the following two will emit to all the sockets connected to `/`
io.sockets.emit('hi', 'everyone');
io.emit('hi', 'everyone'); // short form
WebSockets
• Socket.io
– Do something with the message (client side code)
$(document).ready(function() {
var socket = io.connect('http://xominosocket.mybluemix.net')
// Function to add a message to the page
var hiEvent= function(data) {
alert('Websockets saysnn'+data)
};
// When a refresh message is received from the server, action it
socket.on('hi', function(data) {
hiEvent (data);
});
});
WebSockets
• Socket.io
– Send messages to namespaced pages (page routes)
var nsp = io.of('/my-namespace');
nsp.on('connection', function(socket){
console.log('someone connected'):
});
nsp.emit('hi', 'everyone!');
WebSockets
• Socket.io
– Send messages to users in rooms
io.on('connection', function(socket){
socket.join('some room');
});
io.to('some room').emit('some event'):
WebSockets
• Socket.io
– Send targeted individual messages
• Unique id assigned when user connects to the WebSocket server
• Messages sent to user by id
socket.to(socket_id_here).emit('new', 'hello');
WebSockets
• Socket.io
– Server side chat code
WebSockets
• Socket.io
– Client side chat code
WebSockets
Demonstration Time
WebSockets
• Demonstration 1
– Hot Potato
– https://github.com/shauntrennery/HotPotato
WebSockets
• Demonstration 1
– http://hp.mybluemix.net
WebSockets
• Demonstration 2
– XPages application notification using WebSockets
– Simple yet effective update of fakenames.nsf* data
– *http://www.xpagescheatsheet.com
WebSockets
• Demonstration 3
– Chat room demo
– http://xominosocket.mybluemix.net/
WebSockets
Conclusions
WebSockets
• Websockets
– HTML5, Web standard
– Highly optimized, efficient
– PUSH to user(s)
– Cross-Domain
– Modern Web Browser compatible
– Very cool :)
WebSockets
Questions ?
For more information on WebSockets, XPages and
Application Modernization
mroden@psclistens.com
twitter: @markyroden
skype: marky.roden

More Related Content

What's hot

What's hot (20)

Build a Basic Cloud Using RDO-manager
Build a Basic Cloud Using RDO-managerBuild a Basic Cloud Using RDO-manager
Build a Basic Cloud Using RDO-manager
 
Deploying OpenStack Using Docker in Production
Deploying OpenStack Using Docker in ProductionDeploying OpenStack Using Docker in Production
Deploying OpenStack Using Docker in Production
 
OpenShift for Java EE Developers
OpenShift for Java EE DevelopersOpenShift for Java EE Developers
OpenShift for Java EE Developers
 
Compare Docker deployment options in the public cloud
Compare Docker deployment options in the public cloudCompare Docker deployment options in the public cloud
Compare Docker deployment options in the public cloud
 
DockerCon EU 2015: The Latest in Docker Engine
DockerCon EU 2015: The Latest in Docker EngineDockerCon EU 2015: The Latest in Docker Engine
DockerCon EU 2015: The Latest in Docker Engine
 
Serverless / FaaS / Lambda and how it relates to Microservices
Serverless / FaaS / Lambda and how it relates to MicroservicesServerless / FaaS / Lambda and how it relates to Microservices
Serverless / FaaS / Lambda and how it relates to Microservices
 
Docker Meetup 08 03-2016
Docker Meetup 08 03-2016Docker Meetup 08 03-2016
Docker Meetup 08 03-2016
 
Kubernetes Architecture - beyond a black box - Part 1
Kubernetes Architecture - beyond a black box - Part 1Kubernetes Architecture - beyond a black box - Part 1
Kubernetes Architecture - beyond a black box - Part 1
 
Docker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup Slides
 
Orchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failuresOrchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failures
 
Docker for any type of workload and any IT Infrastructure
Docker for any type of workload and any IT InfrastructureDocker for any type of workload and any IT Infrastructure
Docker for any type of workload and any IT Infrastructure
 
Immutable Awesomeness by John Willis and Josh Corman
Immutable Awesomeness by John Willis and Josh CormanImmutable Awesomeness by John Willis and Josh Corman
Immutable Awesomeness by John Willis and Josh Corman
 
Microservices Runtimes
Microservices RuntimesMicroservices Runtimes
Microservices Runtimes
 
Open shift enterprise 3.1 paas on kubernetes
Open shift enterprise 3.1   paas on kubernetesOpen shift enterprise 3.1   paas on kubernetes
Open shift enterprise 3.1 paas on kubernetes
 
Containers & Security
Containers & SecurityContainers & Security
Containers & Security
 
NetflixOSS for Triangle Devops Oct 2013
NetflixOSS for Triangle Devops Oct 2013NetflixOSS for Triangle Devops Oct 2013
NetflixOSS for Triangle Devops Oct 2013
 
An Evaluation of OpenStack Deployment Frameworks
An Evaluation of OpenStack Deployment FrameworksAn Evaluation of OpenStack Deployment Frameworks
An Evaluation of OpenStack Deployment Frameworks
 
Building a smarter application Stack by Tomas Doran from Yelp
Building a smarter application Stack by Tomas Doran from YelpBuilding a smarter application Stack by Tomas Doran from Yelp
Building a smarter application Stack by Tomas Doran from Yelp
 
Automating the CI / CD pipeline of your containerized applications
Automating the CI / CD pipeline of your containerized applicationsAutomating the CI / CD pipeline of your containerized applications
Automating the CI / CD pipeline of your containerized applications
 
Oracle Java Cloud Service JCS (and WebLogic 12c) - What you Should Know
Oracle Java Cloud Service JCS (and WebLogic 12c) - What you Should KnowOracle Java Cloud Service JCS (and WebLogic 12c) - What you Should Know
Oracle Java Cloud Service JCS (and WebLogic 12c) - What you Should Know
 

Viewers also liked

HTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive ListHTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive List
Mainstreethost
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
Mark Roden
 
The fork in the road - the Application Modernization Roadmap for Notes/Domin...
The fork in the road -  the Application Modernization Roadmap for Notes/Domin...The fork in the road -  the Application Modernization Roadmap for Notes/Domin...
The fork in the road - the Application Modernization Roadmap for Notes/Domin...
John Head
 

Viewers also liked (16)

JVM Garbage Collection Tuning
JVM Garbage Collection TuningJVM Garbage Collection Tuning
JVM Garbage Collection Tuning
 
Maximize information exchange in your enterprise with AMQP
Maximize information exchange in your enterprise with AMQPMaximize information exchange in your enterprise with AMQP
Maximize information exchange in your enterprise with AMQP
 
HTTP/2 Changes Everything
HTTP/2 Changes EverythingHTTP/2 Changes Everything
HTTP/2 Changes Everything
 
The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in Django
 
Reducing load with RabbitMQ
Reducing load with RabbitMQReducing load with RabbitMQ
Reducing load with RabbitMQ
 
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
 
HTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive ListHTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive List
 
AWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media Server
AWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media ServerAWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media Server
AWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media Server
 
Iconus 2016
Iconus 2016Iconus 2016
Iconus 2016
 
Angular.js in XPages
Angular.js in XPagesAngular.js in XPages
Angular.js in XPages
 
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...
 
Ibm worklight - going from xpages mobile to native mobile applications
Ibm worklight - going from xpages mobile to native mobile applicationsIbm worklight - going from xpages mobile to native mobile applications
Ibm worklight - going from xpages mobile to native mobile applications
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
The fork in the road - the Application Modernization Roadmap for Notes/Domin...
The fork in the road -  the Application Modernization Roadmap for Notes/Domin...The fork in the road -  the Application Modernization Roadmap for Notes/Domin...
The fork in the road - the Application Modernization Roadmap for Notes/Domin...
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to Java
 
Partitioning IBM Connections Cloud Administration
Partitioning IBM Connections Cloud AdministrationPartitioning IBM Connections Cloud Administration
Partitioning IBM Connections Cloud Administration
 

Similar to Websockets: Pushing the web forward

Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
Avi Kedar
 
Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010
sullis
 

Similar to Websockets: Pushing the web forward (20)

OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript Applications
 
Node azure
Node azureNode azure
Node azure
 
Node.js for .NET Developers
Node.js for .NET DevelopersNode.js for .NET Developers
Node.js for .NET Developers
 
Js foo - Sept 8 upload
Js foo - Sept 8 uploadJs foo - Sept 8 upload
Js foo - Sept 8 upload
 
PAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark TomlinsonPAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark Tomlinson
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Remix
RemixRemix
Remix
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
 
DevNetCreate Workshop - build a react app - React crash course
DevNetCreate Workshop - build a react app - React crash courseDevNetCreate Workshop - build a react app - React crash course
DevNetCreate Workshop - build a react app - React crash course
 
Short-Training asp.net vNext
Short-Training asp.net vNextShort-Training asp.net vNext
Short-Training asp.net vNext
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10
Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10
Sitecore 10 - ASP.NET Core Rendering with Docker and Sitecore 10
 
WebRTC & Asterisk 11
WebRTC & Asterisk 11WebRTC & Asterisk 11
WebRTC & Asterisk 11
 
An Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows AzureAn Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows Azure
 
Be faster then rabbits
Be faster then rabbitsBe faster then rabbits
Be faster then rabbits
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
DevDay 2018 - Blazor
DevDay 2018 - BlazorDevDay 2018 - Blazor
DevDay 2018 - Blazor
 
Blazor.pptx
Blazor.pptxBlazor.pptx
Blazor.pptx
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Recently uploaded (20)

OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 

Websockets: Pushing the web forward

  • 1. AD117 WebSockets - "Pushing" the web forward Mark Roden PSC Group LLC Principal Architect
  • 2. About Marky Over 18 years IBM Notes Domino® work Principal Architect at PSC Group • XPages Developer • Project Leader • Architect Contact Information – Blog: http://www.xomino.com – Email: marky@xomino.com – Twitter: @markyroden – Skype: marky.roden – "Come work for us - it will be fun" www.psclistens.com @pscgroup
  • 3.
  • 4. WebSockets • What are WebSockets ? • What does that even mean ? • Why do I care ? • Can I use WebSockets ? • When can I use WebSockets – Use Cases – Web Servers • Socket.io • Demonstrations
  • 5. WebSockets • What are WebSockets? • Bi-directional communication over the Web: Both the server and client can send data at any time, or even at the same time. Only the data itself is sent, without the overhead of HTTP headers, dramatically reducing bandwidth – HTML5Rocks.com
  • 7. WebSockets • What does that even mean? – Evolution in browser to server communication – Maximize efficiency in network – Minimize latency
  • 8. WebSockets • What does that even mean? – HTTP Overhead – 803 Bytes
  • 9. WebSockets • What does that even mean? – WebSockets = no HTTP Headers – 86 Bytes
  • 10. WebSockets • What does that even mean? – Before WebSockets - polling • Has anything changed? – No • Has anything changed? – Seriously dude, stop asking you are wasting bandwidth • Has anything changed? – Man, you people are impatient • Has anything changed? – No • Has anything changed? – Sure, let’s go with yes. Hang on while I get that for you.....
  • 11. WebSockets • What does that even mean? – Before WebSockets • Click button to perform server side task..... – Waiting – Waiting – Waiting – Go get a coffee – Server timed out – Repeat....
  • 12. WebSockets • What does that even mean? – Using WebSockets – Real-Time Update • Hey Server can you do this job for me and let me know when it is done? – Sure • OK, time to be productive • ..........some time later – Hey Marky here is your answer........
  • 13. WebSockets • What does that even mean? – Be nice to your users – They don’t *want* to call the help desk......
  • 14. WebSockets Why should I care about WebSockets ?
  • 15. WebSockets • Why should I care about WebSockets ? – W3C Defined JavaScript API – Originally proposed as part of HTML5 – IETF-defined Protocol: RFC 6455 – Cross-Domain – Secure
  • 16. WebSockets • Websockets vs REST – http://blog.arungupta.me/rest-vs-websocket-comparison- benchmarks/ • Arun Gupta – Java Champion
  • 17. WebSockets When can I use WebSockets ?
  • 18. WebSockets • When can I use WebSockets ? – Standard in modern browsers (Aug 2015) • http://caniuse.com/#feat=websockets Windows Internet Explorer 9 - March 14, 2011
  • 20. WebSockets • WebSockets Use cases – Instant notification of events • Web Chat • New items requiring action • General notification • Rapidly changing data – Optimization • Lower bandwith • Lower memory usage • Control of when a user receives the information • Notification regardless of where the user is (within the domain)
  • 21. WebSockets • Websockets Use cases – Better user experience – Chat rooms – Data refresh without polling – Workflow event notification – Social Feeds – Location based applications – Sports updates
  • 22. WebSockets So why aren’t we all using WebSockets already?
  • 23. WebSockets • So why aren’t we all using WebSockets ? – Internet Explorer 9 – Search Engine Optimization – HTTP has many good points • Caching, routing, multiplexing, gzipping and lot more. – Firewalls understand HTTP
  • 25. WebSockets • WebSockets Servers – Jave EE 7 servers • WebSphere • jBoss • Jetty • jWebSocket – Tomcat
  • 26. WebSockets • WebSockets Servers – Domino – via jWebSockets OSGI plugin • http://www.openntf.org/main.nsf/project.xsp?r=project/w ebshell-xpages-ext-lib • http://xomino.com/2014/05/15/websockets-comes-to- xpages-awesome-awesome-awesome/
  • 27. WebSockets • WebSockets Servers – Node.js • http://Socket.io • JavaScript on the server • JavaScript on the client
  • 29. WebSockets • Socket.io setup – Server side • Install Node.js server • npm install --save express • npm install --save socket.io – Client side • <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
  • 30. WebSockets • Socket.io – Send message to everyone connected – Send messages to namespaced web pages – Send group messages to users in a “room” – Send targeted individual messages – Users can be on any domain, but must be connected to the same WebSockets server
  • 31. WebSockets • Socket.io – Send message to everyone (server side code) // the following two will emit to all the sockets connected to `/` io.sockets.emit('hi', 'everyone'); io.emit('hi', 'everyone'); // short form
  • 32. WebSockets • Socket.io – Do something with the message (client side code) $(document).ready(function() { var socket = io.connect('http://xominosocket.mybluemix.net') // Function to add a message to the page var hiEvent= function(data) { alert('Websockets saysnn'+data) }; // When a refresh message is received from the server, action it socket.on('hi', function(data) { hiEvent (data); }); });
  • 33. WebSockets • Socket.io – Send messages to namespaced pages (page routes) var nsp = io.of('/my-namespace'); nsp.on('connection', function(socket){ console.log('someone connected'): }); nsp.emit('hi', 'everyone!');
  • 34. WebSockets • Socket.io – Send messages to users in rooms io.on('connection', function(socket){ socket.join('some room'); }); io.to('some room').emit('some event'):
  • 35. WebSockets • Socket.io – Send targeted individual messages • Unique id assigned when user connects to the WebSocket server • Messages sent to user by id socket.to(socket_id_here).emit('new', 'hello');
  • 39. WebSockets • Demonstration 1 – Hot Potato – https://github.com/shauntrennery/HotPotato
  • 40. WebSockets • Demonstration 1 – http://hp.mybluemix.net
  • 41. WebSockets • Demonstration 2 – XPages application notification using WebSockets – Simple yet effective update of fakenames.nsf* data – *http://www.xpagescheatsheet.com
  • 42. WebSockets • Demonstration 3 – Chat room demo – http://xominosocket.mybluemix.net/
  • 44. WebSockets • Websockets – HTML5, Web standard – Highly optimized, efficient – PUSH to user(s) – Cross-Domain – Modern Web Browser compatible – Very cool :)
  • 45. WebSockets Questions ? For more information on WebSockets, XPages and Application Modernization mroden@psclistens.com twitter: @markyroden skype: marky.roden