Introduction au WebSockets via le projet Atmosphere
1. WebSockets et Atmosphere
Jeanfrancois Arcand
twitter.com/jfarcand
facebook.com/jeanfrancois.arcand.3
2. Who is Wordnik?
• Founded in 2008 by Erin McKean
• "Understand meaning of words
automatically"
• Patented "Free-Range Definition"
technology
• Constructed largest (known) English Word
Graph
We do Discovery – in real time!!
3. Atmosphere
Apache 2 Github ~450
« followers »
Client +
Supporté server
par + de 25
frameworks Scala, Groovy,
JRuby, Java
Depuis
20 000 et plus
2008
téléchargement par
1.0.0.beta1 mois!
4. Atmosphere
Apache 2 Github ~450
« followers »
Client +
Supporté Très Très
server
par + de 25 actif!!!
frameworks Scala, Groovy,
JRuby, Java
Depuis
20 000 et plus
2008
téléchargement par
mois!
5. WSJ.com
• 40 millions de requêtes par jours
• Atmosphere 0.9.4/Jetty 8.1.3
• Websockets => long-polling => JSONP
• IE 6/7/8/9/10, Chrome XX, Firefox 3/12,
Safari XX
• WebSockets: IE 10, Chrome 14, Firefox
8, Safari 5
9. Mon WebSocket au Canada!
WebSocket
C’est quoi N’importe
quoi!
Atmospher
e
10. Mon WebSocket au Canada!
WebSocket
C’est quoi N’importe
quoi!
Atmospher
e
Concepts
11. Mon WebSocket au Canada!
WebSocket
C’est quoi N’importe
quoi!
Atmospher
e
Concepts Démo
12. WebSockets
Le protocole WebSocket vise à
développer un canal de
communication bidirectionnel
et « full-duplex » sur un
socket TCP pour les fureteurs
et les serveurs web.
47. Ah la belle vie, la vie, la vie, ahah
T 127.0.0.1:8080 -> 127.0.0.1:51292 [AP]
HTTP/1.1 101 Switching Protocols.
Upgrade: WebSocket.
Connection: Upgrade.
Sec-WebSocket-Accept:
HVXA7SqH5uYeN6aD9tZ0JQbfTJA=.
48. OUPS!!!
T 127.0.0.1:8080 -> 127.0.0.1:65064 [AP]
HTTP/1.1 501 Not Implemented.
Server: Apache-Coyote/1.1.
X-Atmosphere-error: Websocket protocol not
supported.
Transfer-Encoding: chunked.
Date: Fri, 15 Jun 2012 10:06:30 GMT.
Connection: close.
.
53. C’est parti!
Safari Tomcat
7
Firefox Jetty7
Jetty8
Chrome
GlassFis
Opera h3.
GlassFis
IE h
312
54. N’importe quoi
Safari Tomcat
7
Firefox Jetty7
Jetty8
Chrome
GlassFis
Opera h3.
GlassFis
IE h
312
55. N’importe quoi
Safari Tomcat
7
Firefox Jetty7
Au Jetty8
Chrome
Secours
GlassFis
Opera !! h3.
GlassFis
IE h
312
56. N’importe quoi
Safari Tomcat
7
Streamin Jetty7
Firefox
g
Au Jetty8
Chrome
Secours
GlassFis
Opera !! h3.
GlassFis
IE h
312
57. N’importe quoi
Safari Tomcat
7
Streamin Jetty7
Firefox
g
Au SSE Jetty8
Chrome
Secours
GlassFis
Opera !! h3.
GlassFis
IE h
312
58. N’importe quoi
Safari Tomcat
7
Streamin Jetty7
Firefox
g
Au SSE Jetty8
Chrome
Secours
GlassFis
Opera !! JSONP
h3.
GlassFis
IE h
312
59. N’importe quoi
Safari Tomcat
7
Streamin Jetty7
Firefox
g
Au SSE Jetty8
Chrome
Secours
GlassFis
Opera !! JSONP
h3.
Long
GlassFis
IE Polling h
312
60. Safari Tomcat
7
Firefox Jetty7
Atmosphere à
Chrome la Jetty8
rescousse!!! GlassFis
Opera h3.
GlassFis
IE h
312
61. Atmosphere -WebSockets
Safari Tomcat
7
Jetty7
Atmosphere API
Firefox
atmosphere.js
Jetty8
Chrome
GlassFis
Opera h3.
GlassFis
IE h
312
62. Atmosphere - HTML5 Server Side
Events
Safari Tomcat
7
Jetty7
Atmosphere API
Firefox
atmosphere.js
Servlet
Chrome
3
WebLogi
Opera c
GlassFis
IE h
312
63. Atmosphere Long-Polling/HTTP
Streaming
Safari JBoss
Jetty7
Atmosphere API
Firefox
atmosphere.js
Servlet
Chrome
3
WebLogi
Opera c.
GlassFis
IE h
64. Atmosphere
Safari JBoss
Jetty7
Atmosphere API
Firefox
atmosphere.js
Même API,
Chrome peut importe Servlet
3
le transport!! WebLogi
Opera c.
GlassFis
IE h
65. Socket.IO, GWT, Wicket, JSF, etc.
Safari JBoss
Jetty7
Atmosphere API
Firefox
Socket.IO
Servlet
Chrome
3
WebLogi
Opera c.
GlassFis
IE h
66. PORTABLE!!!!!
Safari JBoss
Jetty7
Atmosphere API
Firefox
Socket.IO
PORTABLE Servlet
Chrome
3
WebLogi
Opera c.
GlassFis
IE h
87. Composantes Atmosphere
• WebSocketHandler
• Seulement WebSocket (ATTENTION)!
• AtmosphereHandler
• Tout les protocoles
• Jersey Resource
• Tout les protocoles
• Meteor
• Tout les protocoles
88. WebSocket Sub Protocol
• WebSocketProtocol
Definir sont propre WebSocket protocol.
• Atmosphere,par default,
utilise le SimpleHttpProtocol
Message WebSocket transformé en HTTP
POST, avec read/write asynchrone.
• SwaggerSocket:REST over
WebSockets -> Protocol plus
puissant
90. Hello, Swagger
• Swagger is…
• Spec for declaring an API schema
• A framework for auto-generating the spec
• A library for client library generation
• A JSON-based test framework
91. What is this Resource Declaration?
• Listing of all available APIs
http://petstore.swagger.wordnik.com/api/resources.json
“It’s like a
sitemap for
your API!”
93. But What about Speed?
• Yes! REST over HTTP is slow
• Connection overhead
• Your
Marshaling & Unmarshaling overhead prod
• Chatter Database
• JSON/XML need to diet isn't doing
• It's also… REST
• Synchronous
• GET/POST/PUT/DELETE don't cut it
94. SwaggerSocket
• REST over WebSocket
• Protocole basé sur JSON
• Performance améliorée
• Simple
• Supporte également sur HTTP.
• Supporte le multi
requètes/réponses.
95. Powered By Wordnik
twitter.com/wordnik
twitter.com/atmo_framework
twitter.com/swaggersocket
http://github.com/Atmosphere/atmosphere
http://github.com/wordnik/swaggersocket