SlideShare a Scribd company logo
Alex carcea, radu macovei   a story of how java script joined the big league
WELCOME!
Alex carcea, radu macovei   a story of how java script joined the big league
A STORY OF HOW JAVASCRIPT JOINED THE BIG LEAGUE: 
WEBSOCKETS 
AND OTHER GOODIES 
Created by Alexandru Carcea & Radu Macovei
Alex carcea, radu macovei   a story of how java script joined the big league
A FEW WORDS ABOUT 
JAVASCRIPT
HISTORY 
OF JAVASCRIPT
Alex carcea, radu macovei   a story of how java script joined the big league
OBJECTS AND CLASSES 
IN JAVASCRIPT
DOM MANIPULATION 
IN JAVASCRIPT
EVENTS 
IN JAVASCRIPT
REAL TIME WEB 
WHEN USERS ALMOST FORGOT ABOUT 
REFRESHING WEB PAGES
HTTP 
THE PROTOCOL THAT ENABLES THE WEB 
AND ITS SHORTCOMINGS
Alex carcea, radu macovei   a story of how java script joined the big league
ALMOST REAL TIME 
HACKS TO SIMULATE REAL TIME WEB
XMLHTTPREQUEST 
AND AJAX 
RETRIEVING DATA WITHOUT FULL PAGE REFRESH
POLLING AND 
LONG POLLING 
TRYING TO ACHIEVE REAL TIME
WEBSOCKETS 
THE PROTOCOL THAT PROVIDES REAL TIME, FULL-DUPLEX 
COMMUNICATION
Alex carcea, radu macovei   a story of how java script joined the big league
WS VS HTTP 
GETTING RID OF HEADERS THAT ARE NOT NEEDED
TMI! TMFI! 
GET / HTTP/1.1 
Host: www.example.com 
Connection: keep‐alive 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 
User‐Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2194.2 Safari/Accept‐Encoding: gzip, deflate, sdch 
Accept‐Language: ro‐RO,ro;q=0.8,en‐US;q=0.6,en;q=0.4 
X‐Custom‐Headers: Whoa, overhead!
... AND THIS HAPPENS 
EVERY SINGLE TIME! 
HTTP/1.1 200 OK 
Accept‐Ranges: bytes 
Cache‐Control: max‐age=604800 
Content‐Type: text/html 
Date: Thu, 15 Jan 1970 00:00:00 GMT 
Etag: "359670651" 
Expires: Sat, 31 Jan 1970 00:00:00 GMT 
Last‐Modified: Thu, 01 Jan 1970 00:00:00 GMT 
Server: Apache 
Content‐Length: 51 
Hello World! My payload includes a trailing CRLF.
LET'S TRY WITH 
WEBSOCKETS 
GET /chat HTTP/1.1 
Host: server.example.com 
Upgrade: websocket 
Connection: Upgrade 
Sec‐WebSocket‐Key: x3JJHMbDL1EzLkh9GBhXDw== 
Sec‐WebSocket‐Protocol: chat, superchat 
Sec‐WebSocket‐Version: 13 
Origin: http://example.com
THAT'S BETTER... 
HTTP/1.1 101 Switching Protocols 
Upgrade: websocket 
Connection: Upgrade 
Sec‐WebSocket‐Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk= 
Sec‐WebSocket‐Protocol: chat
JAVASCRIPT 
WEBSOCKETS 
CLIENT API 
WRITE WEBSOCKET CLIENT APPLICATIONS USING 
WEBSOCKET CLASS
WEBSOCKET API 
EVENTS 
1. open 
2. message 
3. close 
4. error
WEBSOCKET API 
METHODS 
1. send(data) 
2. close()
WEBSOCKET API 
if ("WebSocket" in window) { 
// WebSocket is supported 
var ws = new WebSocket("[ws|wss]://[host]:[port]/[uri]", [protocol(s)]); 
ws.onopen = function (event) { ... }; 
ws.onmessage = function (event) { ... }; 
ws.onclose = function (event) { ... }; 
ws.onerror = function (event) { ... }; 
ws.send(data); 
// ws.close(); when finished 
} else { 
// WebSocket NOT supported 
}
WEBSOCKETS 
CLIENT 
LIBRARIES 
ws 
engine.io 
socket.io 
primus
USES FOR WEBSOCKETS 
Social feeds 
Multiplayer games 
Collaborative tools 
Financial apps 
Sports apps 
... and many more ...
A SMALL 
WEBSOCKETS 
DEMO
USING NODE.JS 
AND SOCKET.IO
Alex carcea, radu macovei   a story of how java script joined the big league
Q&A
THANK YOU!

More Related Content

PDF
Web Sockets - HTML5
PPTX
Web Sockets
PDF
Introduction to Web Sockets
PDF
COMET in Plone
PDF
Websocket 101 in Python
PDF
Open web mail setup
PDF
Cowboy rabbit-websockets
PPT
WebSockets and Java
Web Sockets - HTML5
Web Sockets
Introduction to Web Sockets
COMET in Plone
Websocket 101 in Python
Open web mail setup
Cowboy rabbit-websockets
WebSockets and Java

What's hot (20)

PPTX
Websockets
PPTX
Web socket with php v2
PPTX
Std12 Chapter-3 Designing Simple Websites Using Kompozer
PPTX
Websocket
PDF
HTTP2 is Here!
PDF
Timeless - Websocket on Rails
PPTX
Smuggling TCP traffic through HTTP
ODP
WebSockets with PHP: Mission impossible
PDF
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
PPTX
Codecamp iasi-26 nov 2011-web sockets
PDF
CodeCamp Iasi 10 march 2012 - websockets-with-atmosphere
PDF
[Greach 2016] Down The RabbitMQ Hole
PDF
How To Install Apache, MySQL & PHP on Windows Vista
PPTX
Getting the most out of WebPageTest
PPT
DEV301- Web Service Programming with WCF 3.5
PDF
Jetty and Tomcat
PDF
Speedup your WordPress mit Nginx und HTTP/2
PPTX
REST in the shade of WCF
PDF
Rails Conf Europe 2007 - Utilizing Amazon S3 and EC2 in Rails
PDF
Using Communication and Messaging API in the HTML5 World
Websockets
Web socket with php v2
Std12 Chapter-3 Designing Simple Websites Using Kompozer
Websocket
HTTP2 is Here!
Timeless - Websocket on Rails
Smuggling TCP traffic through HTTP
WebSockets with PHP: Mission impossible
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
Codecamp iasi-26 nov 2011-web sockets
CodeCamp Iasi 10 march 2012 - websockets-with-atmosphere
[Greach 2016] Down The RabbitMQ Hole
How To Install Apache, MySQL & PHP on Windows Vista
Getting the most out of WebPageTest
DEV301- Web Service Programming with WCF 3.5
Jetty and Tomcat
Speedup your WordPress mit Nginx und HTTP/2
REST in the shade of WCF
Rails Conf Europe 2007 - Utilizing Amazon S3 and EC2 in Rails
Using Communication and Messaging API in the HTML5 World
Ad

Viewers also liked (8)

PPTX
Iasi code camp 20 april 2013 windows authentication-spring security -kerberos
PPTX
Jozua velle + silviu luca dev ops
PPTX
Alex lakatos state of mobile web
PDF
Iasi codecamp 20 april 2013 scrum- agile measurements-dan nicola
PDF
Iasi codecamp 20 april 2013 it–a career a life sweat smiles and cries –andrei...
PPTX
Iasi codecamp 20 april 2013 sponsors 5 minutes presentations
PDF
Georges Chitiga - Introduction to Phonegap - HTML5 & JS to native mobile app
PDF
Ciprian ouatu asertivitate - comportament si comunicare
Iasi code camp 20 april 2013 windows authentication-spring security -kerberos
Jozua velle + silviu luca dev ops
Alex lakatos state of mobile web
Iasi codecamp 20 april 2013 scrum- agile measurements-dan nicola
Iasi codecamp 20 april 2013 it–a career a life sweat smiles and cries –andrei...
Iasi codecamp 20 april 2013 sponsors 5 minutes presentations
Georges Chitiga - Introduction to Phonegap - HTML5 & JS to native mobile app
Ciprian ouatu asertivitate - comportament si comunicare
Ad

Similar to Alex carcea, radu macovei a story of how java script joined the big league (20)

PDF
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
PDF
Building Next Generation Real-Time Web Applications using Websockets
KEY
The HTML5 WebSocket API
PPT
PPTX
WebSockets in JEE 7
PPT
JUG louvain websockets
PPTX
WebSocket protocol
PPTX
HTML 5 - Web Sockets
PPTX
PDF
HTML5/JavaScript Communication APIs - DPC 2014
PPTX
V2 peter-lubbers-sf-jug-websocket
PDF
HTML5 WebSockets
ZIP
Websockets at tossug
KEY
Socket.io
PDF
WebSocket
PDF
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
PDF
DevCon 5 (July 2013) - WebSockets
PDF
SeaBeyond 2011 ProcessOne - Eric Cestari: XMPP over WebSocket
PPT
Get Real: Adventures in realtime web apps
PDF
Web sockets in java EE 7 - JavaOne 2013
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
Building Next Generation Real-Time Web Applications using Websockets
The HTML5 WebSocket API
WebSockets in JEE 7
JUG louvain websockets
WebSocket protocol
HTML 5 - Web Sockets
HTML5/JavaScript Communication APIs - DPC 2014
V2 peter-lubbers-sf-jug-websocket
HTML5 WebSockets
Websockets at tossug
Socket.io
WebSocket
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
DevCon 5 (July 2013) - WebSockets
SeaBeyond 2011 ProcessOne - Eric Cestari: XMPP over WebSocket
Get Real: Adventures in realtime web apps
Web sockets in java EE 7 - JavaOne 2013

More from Codecamp Romania (20)

PDF
Cezar chitac the edge of experience
PPTX
Cloud powered search
PPTX
Business analysis techniques exercise your 6-pack
PPTX
Bpm company code camp - configuration or coding with pega
PPT
Andrei prisacaru takingtheunitteststothedatabase
PPTX
Agility and life
PPTX
2015 dan ardelean develop for windows 10
PDF
The bigrewrite
PDF
The case for continuous delivery
PPTX
Stefan stolniceanu spritekit, 2 d or not 2d
PPTX
Sizing epics tales from an agile kingdom
PPTX
Scale net apps in aws
PPTX
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
PPTX
Parallel & async processing using tpl dataflow
PDF
Material design screen transitions in android
PDF
Kickstart your own freelancing career
PDF
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
PDF
Ecma6 in the wild
PPTX
Diana antohi me against myself or how to fail and move forward
Cezar chitac the edge of experience
Cloud powered search
Business analysis techniques exercise your 6-pack
Bpm company code camp - configuration or coding with pega
Andrei prisacaru takingtheunitteststothedatabase
Agility and life
2015 dan ardelean develop for windows 10
The bigrewrite
The case for continuous delivery
Stefan stolniceanu spritekit, 2 d or not 2d
Sizing epics tales from an agile kingdom
Scale net apps in aws
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
Parallel & async processing using tpl dataflow
Material design screen transitions in android
Kickstart your own freelancing career
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
Ecma6 in the wild
Diana antohi me against myself or how to fail and move forward

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Spectroscopy.pptx food analysis technology
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Cloud computing and distributed systems.
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Big Data Technologies - Introduction.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Unlocking AI with Model Context Protocol (MCP)
Spectroscopy.pptx food analysis technology
Spectral efficient network and resource selection model in 5G networks
Cloud computing and distributed systems.
“AI and Expert System Decision Support & Business Intelligence Systems”
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...
Machine learning based COVID-19 study performance prediction
Big Data Technologies - Introduction.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Review of recent advances in non-invasive hemoglobin estimation
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

Alex carcea, radu macovei a story of how java script joined the big league

  • 4. A STORY OF HOW JAVASCRIPT JOINED THE BIG LEAGUE: WEBSOCKETS AND OTHER GOODIES Created by Alexandru Carcea & Radu Macovei
  • 6. A FEW WORDS ABOUT JAVASCRIPT
  • 9. OBJECTS AND CLASSES IN JAVASCRIPT
  • 10. DOM MANIPULATION IN JAVASCRIPT
  • 12. REAL TIME WEB WHEN USERS ALMOST FORGOT ABOUT REFRESHING WEB PAGES
  • 13. HTTP THE PROTOCOL THAT ENABLES THE WEB AND ITS SHORTCOMINGS
  • 15. ALMOST REAL TIME HACKS TO SIMULATE REAL TIME WEB
  • 16. XMLHTTPREQUEST AND AJAX RETRIEVING DATA WITHOUT FULL PAGE REFRESH
  • 17. POLLING AND LONG POLLING TRYING TO ACHIEVE REAL TIME
  • 18. WEBSOCKETS THE PROTOCOL THAT PROVIDES REAL TIME, FULL-DUPLEX COMMUNICATION
  • 20. WS VS HTTP GETTING RID OF HEADERS THAT ARE NOT NEEDED
  • 21. TMI! TMFI! GET / HTTP/1.1 Host: www.example.com Connection: keep‐alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 User‐Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2194.2 Safari/Accept‐Encoding: gzip, deflate, sdch Accept‐Language: ro‐RO,ro;q=0.8,en‐US;q=0.6,en;q=0.4 X‐Custom‐Headers: Whoa, overhead!
  • 22. ... AND THIS HAPPENS EVERY SINGLE TIME! HTTP/1.1 200 OK Accept‐Ranges: bytes Cache‐Control: max‐age=604800 Content‐Type: text/html Date: Thu, 15 Jan 1970 00:00:00 GMT Etag: "359670651" Expires: Sat, 31 Jan 1970 00:00:00 GMT Last‐Modified: Thu, 01 Jan 1970 00:00:00 GMT Server: Apache Content‐Length: 51 Hello World! My payload includes a trailing CRLF.
  • 23. LET'S TRY WITH WEBSOCKETS GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec‐WebSocket‐Key: x3JJHMbDL1EzLkh9GBhXDw== Sec‐WebSocket‐Protocol: chat, superchat Sec‐WebSocket‐Version: 13 Origin: http://example.com
  • 24. THAT'S BETTER... HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec‐WebSocket‐Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk= Sec‐WebSocket‐Protocol: chat
  • 25. JAVASCRIPT WEBSOCKETS CLIENT API WRITE WEBSOCKET CLIENT APPLICATIONS USING WEBSOCKET CLASS
  • 26. WEBSOCKET API EVENTS 1. open 2. message 3. close 4. error
  • 27. WEBSOCKET API METHODS 1. send(data) 2. close()
  • 28. WEBSOCKET API if ("WebSocket" in window) { // WebSocket is supported var ws = new WebSocket("[ws|wss]://[host]:[port]/[uri]", [protocol(s)]); ws.onopen = function (event) { ... }; ws.onmessage = function (event) { ... }; ws.onclose = function (event) { ... }; ws.onerror = function (event) { ... }; ws.send(data); // ws.close(); when finished } else { // WebSocket NOT supported }
  • 29. WEBSOCKETS CLIENT LIBRARIES ws engine.io socket.io primus
  • 30. USES FOR WEBSOCKETS Social feeds Multiplayer games Collaborative tools Financial apps Sports apps ... and many more ...
  • 32. USING NODE.JS AND SOCKET.IO
  • 34. Q&A