Writing Portable WebSockets in Java
-
Upload
jfarcand -
Category
Technology
-
view
2.397 -
download
2
description
Transcript of Writing Portable WebSockets in Java
![Page 1: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/1.jpg)
Writing Portable WebSocket in Java
Jeanfrancois Arcand
twitter.com/jfarcand
![Page 2: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/2.jpg)
Pardon?
•Worked 10 years for Sun Microsystems
• Active Commiter on Tomcat 4/5
• Active Commiter GlassFish 1/2/3
• Glassfish v3 extensible container kernel
• Performance/Scalability
• Creator of the Grizzly NIO Framework
•Creator of the AHC (AsyncHttpClient) library
•Creator of Atmosphere
![Page 3: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/3.jpg)
Atmosphere
Apache 2 Github ~470 « followers »
20 000 downloads per months
Client + serverSupported
~25 framework
s
Scala, Groovy,
JRuby, Java
1.0.0.beta3
Since 2008
![Page 4: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/4.jpg)
Atmosphere
Apache 2 Github ~450 « followers »
20 000 downloads per months
Client + serverSupported
~25 framework
s
Scala, Groovy,
JRuby, Java
1.0.0.beta2
Since2008
EXTREMELY
ACTIVE !!!
![Page 5: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/5.jpg)
Today’s Presentation
WebSocket
![Page 6: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/6.jpg)
Today’s Presentation
WebSocket
Definition
![Page 7: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/7.jpg)
Today’s Presentation
WebSocket
Free for all!!!
Definition
![Page 8: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/8.jpg)
Today’s Presentation
WebSocket
Free for all!
C’est quoi
Atmosphere
Free for all!!!
Definition
![Page 9: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/9.jpg)
Today’s Presentation
WebSocket
Free for all!
Definition
Atmosphere
Concepts
![Page 10: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/10.jpg)
Today’s Presentation
WebSocket
Free for all!
C’est quoi
Atmosphere
DemoConcepts
Free for all!!!
Definition
![Page 11: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/11.jpg)
is a web technology providing for bi-directional, full-duplex
communications channels over a single TCP connection. The WebSocket API is being
standardized by the W3C, and the WebSocket protocol has been
standardized by the IETF as RFC 6455
WebSockets
![Page 12: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/12.jpg)
Before (Long-Polling)
Browser
Server
Request
![Page 13: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/13.jpg)
Before (Long-Polling)
Browser
Request
Server
![Page 14: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/14.jpg)
Before (Long-Polling)
Browser
Request
Response
Server
![Page 15: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/15.jpg)
Oups!!
Browser
ServerNone
Request
![Page 16: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/16.jpg)
Oups!
Browser
Request
Server
Zzzz
![Page 17: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/17.jpg)
Better!
Browser
Server
Cache
Request
![Page 18: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/18.jpg)
Better!
Request
Server
Cache
Response
Browser
![Page 19: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/19.jpg)
Pushing the Protocol (HTTP Streaming)
Browser
Server
Request
![Page 20: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/20.jpg)
Pushing the Protocol (HTTP Streaming)
Browser
Request
Server
![Page 21: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/21.jpg)
Pushing the Protocol (HTTP Streaming)
Browser
Request
Response
Server
![Page 22: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/22.jpg)
Pushing the Protocol (HTTP Streaming)
Browser
Request
Response
Response
Server
![Page 23: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/23.jpg)
Oups!!
Browser
Request
Response
Response
Server
Hell!!!
![Page 24: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/24.jpg)
Pushing the Protocol (HTTP Streaming)
Browser
Request
Response
Response
Server
Hell!!!
Hack
![Page 25: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/25.jpg)
Oups!!!
Browser
Request
Response
Response
Server
Proxy
![Page 26: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/26.jpg)
Better
Browser
Request
Response
Response
Server
Cache
![Page 27: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/27.jpg)
Better
Browser
Request
Response
Response
Server
Cache« HeartBea
t »
![Page 28: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/28.jpg)
Better: Server Side Events (SSE)
Browser
Request
Response
Response
Server
![Page 29: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/29.jpg)
Oups!!!
Browser
Request
Response
Response
Server
Proxy
![Page 30: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/30.jpg)
Better
Browser
Request
Response
Response
Server
Cache« HeartBea
t »
![Page 31: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/31.jpg)
WebSockets
Browser
Server
Hanshake
![Page 32: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/32.jpg)
WebSockets
Browser
Server
Hanshake
OK
![Page 33: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/33.jpg)
WebSockets
Browser
Server
Request
![Page 34: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/34.jpg)
WebSockets
Browser
Request
Server
![Page 35: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/35.jpg)
WebSockets
Browser
Server
Response
![Page 36: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/36.jpg)
WebSockets
Browser
Server
Request
![Page 37: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/37.jpg)
WebSockets
Browser
Server
Request
Request
![Page 38: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/38.jpg)
WebSockets
Browser
Request
Request
Server
![Page 39: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/39.jpg)
WebSockets
Browser
Server
Response
Response
![Page 40: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/40.jpg)
Anytime
Browser
Response
Server
![Page 41: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/41.jpg)
Life is good, lalalalalala
Browser
Response
Server
![Page 42: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/42.jpg)
Oups!!
Browser
Response
Server
Proxy
![Page 43: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/43.jpg)
Better!
Browser
Response
Server
Cache
![Page 44: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/44.jpg)
T 127.0.0.1:65062 -> 127.0.0.1:8080 [AP]
GET / HTTP/1.1.
Upgrade: websocket.
Connection: Upgrade.
Host: 127.0.0.1:8080.
Origin: http://127.0.0.1:8080.
Sec-WebSocket-Key: Tz9qdt3lmte6Slf+GvpRqQ==.
Sec-WebSocket-Version: 13.
Sec-WebSocket-Extensions: x-webkit-deflate-frame.
First Request
![Page 45: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/45.jpg)
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=.
Response
![Page 46: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/46.jpg)
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=.
Life is good, lalalalalala
![Page 47: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/47.jpg)
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.
.
OUPS!!!
![Page 48: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/48.jpg)
WebSocket API – Standard JavaScript
websocket = new WebSocket(wsUri);
websocket.onopen = function(evt) { …};
websocket.onclose = function(evt) { …};
websocket.onmessage = function(evt) { …};
websocket.onerror = function(evt) { …};
webSocket.send(…)
![Page 49: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/49.jpg)
WebSocket API – Java
Jetty 7, GlassFish 3.1, Netty 3, Tomcat 7.0.27, Resin 4, JBoss Plugin
JSR 356: http://jcp.org/en/jsr/detail?id=356
AHC (Client -> De facto)
http://github.com/sonatype/async-http-client
![Page 50: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/50.jpg)
Life is good, lalalalalala
![Page 51: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/51.jpg)
OUPS!!!
![Page 52: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/52.jpg)
Ready?
Tomcat7
Jetty7
Jetty8
GlassFish3.
GlassFish
312
Firefox
Safari
Opera
Chrome
IE
![Page 53: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/53.jpg)
Free for all
Tomcat7
Jetty7
Jetty8
GlassFish3.
GlassFish
312
Firefox
Safari
Opera
Chrome
IE
![Page 54: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/54.jpg)
Free for all
Tomcat7
Jetty7
Jetty8
GlassFish3.
GlassFish
312
Firefox
Safari
Opera
Chrome
IE
Imdat!!
![Page 55: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/55.jpg)
Free for all
Tomcat7
Jetty7
Jetty8
GlassFish3.
GlassFish
312
Firefox
Safari
Opera
Chrome
IE
Imdat!!
Streaming
![Page 56: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/56.jpg)
Free for all
Tomcat7
Jetty7
Jetty8
GlassFish3.
GlassFish
312
Firefox
Safari
Opera
Chrome
IE
Imdat!!
Streaming
SSE
![Page 57: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/57.jpg)
Free for all
Tomcat7
Jetty7
Jetty8
GlassFish3.
GlassFish
312
Firefox
Safari
Opera
Chrome
IE
Imdat!!
Streaming
SSE
JSONP
![Page 58: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/58.jpg)
Free for all
Tomcat7
Jetty7
Jetty8
GlassFish3.
GlassFish
312
Firefox
Safari
Opera
Chrome
IE
Imdat!!
Streaming
SSE
Long Polling
JSONP
![Page 59: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/59.jpg)
Tomcat7
Jetty7
Jetty8
GlassFish3.
GlassFish
312
Firefox
Safari
Opera
Chrome
IE
Atmosphere to the
rescue!!!
![Page 60: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/60.jpg)
Atmosphere -WebSockets
Tomcat7
Jetty7
Jetty8
GlassFish3.
GlassFish
312
Firefox
Safari
Opera
Chrome
IE
atm
osp
here
.js
Atm
osp
here
API
![Page 61: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/61.jpg)
Atmosphere - HTML5 Server Side Events
Tomcat7
Jetty7
Servlet3
WebLogic
GlassFish
312
Firefox
Safari
Opera
Chrome
IE
atm
osp
here
.js
Atm
osp
here
API
![Page 62: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/62.jpg)
Atmosphere Long-Polling/HTTP Streaming
JBoss
Jetty7
Servlet3
WebLogic.
GlassFish
Firefox
Safari
Opera
Chrome
IE
atm
osp
here
.js
Atm
osp
here
API
![Page 63: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/63.jpg)
Atmosphere
JBoss
Jetty7
Servlet3
WebLogic.
GlassFish
Firefox
Safari
Opera
Chrome
IE
atm
osp
here
.js
Atm
osp
here
API
Same API, transport
independent!!
![Page 64: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/64.jpg)
Socket.IO, GWT, Wicket, JSF, etc.
JBoss
Jetty7
Servlet3
WebLogic.
GlassFish
Firefox
Safari
Opera
Chrome
IE
Sock
et.
IO
Atm
osp
here
API
![Page 65: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/65.jpg)
PORTABLE!!!!!
JBoss
Jetty7
Servlet3
WebLogic.
GlassFish
Firefox
Safari
Opera
Chrome
IE
Sock
et.
IO
Atm
osp
here
API
PORTABLE
![Page 66: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/66.jpg)
•Framework that support ONLY WebSockets
Going into Production?IMPOSSIBLE
Big Big Big Mistake
![Page 67: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/67.jpg)
Atmosphere
![Page 68: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/68.jpg)
•Suspend: open a channel
•Resume: close a channel
•Broadcast: push message to one or more channel
Definition
![Page 69: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/69.jpg)
Components
Handler(s)
Atmosphere.js
Interceptor(s)
![Page 70: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/70.jpg)
Components
Handler(s)
Atmosphere.js
Interceptor(s)
Javascript client
![Page 71: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/71.jpg)
Components
Handler(s)
Atmosphere.js
Interceptor(s)
Intercepts/Filters
![Page 72: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/72.jpg)
Components
Handler(s)
Atmosphere.js
Interceptor(s)
Applications Logic
![Page 73: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/73.jpg)
Components
ServletHandler
Atmosphere.js
Interceptor(s)
Your Servlet
![Page 74: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/74.jpg)
Components
ServletHandler
Atmosphere.js
Interceptor(s)
Your Servlet Based
Framework
![Page 75: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/75.jpg)
Components
ServletHandler
Atmosphere.js
Interceptor(s)
Your Servletws
![Page 76: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/76.jpg)
Components
ServletHandler
Atmosphere.js
Interceptor(s)
Your Servletwssse
![Page 77: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/77.jpg)
Components
ServletHandler
Atmosphere.js
Interceptor(s)
Your Servletwsssehtt
p
![Page 78: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/78.jpg)
Request
Browser
Browser
Browser
Server
![Page 79: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/79.jpg)
Request
Browser
Browser
Browser
Server
![Page 80: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/80.jpg)
Suspend
Browser
Browser
Browser
Server
![Page 81: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/81.jpg)
Suspend
Browser
Browser
Browser
ServerS
![Page 82: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/82.jpg)
Suspend
Browser
Browser
Browser
ServerS
![Page 83: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/83.jpg)
Suspend
Browser
Browser
Browser
ServerS
![Page 84: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/84.jpg)
Broadcast
Browser
Browser
Browser
SB
Server
![Page 85: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/85.jpg)
Broadcast
Browser
Browser
Browser
SB
Server
![Page 86: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/86.jpg)
Resume
Browser
Browser
Browser
B
Server
R
![Page 87: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/87.jpg)
Resume
Browser
Browser
Browser
B
ServerS
![Page 88: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/88.jpg)
•Default: in-memory
•Cloud
• RedisBroadcaster
• JMSBroadcaster
• XMPPBroadcaster
• HazelcastBroadcaster
• JGroupsBroascaster
•Multi-Threads, Async I/O par default
Broadcaster
![Page 89: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/89.jpg)
Broadcaster Cloud
Browser
Browser
Browser S
Server
ServerS
![Page 90: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/90.jpg)
Broadcaster Cloud
Browser
Browser
Browser S
Server
ServerS
![Page 91: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/91.jpg)
Broadcaster Cloud
Browser
Browser
Browser S
B
Server
ServerS
![Page 92: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/92.jpg)
Broadcaster Cloud
Browser
Browser
Browser
BServer
Server
![Page 93: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/93.jpg)
Broadcaster Cloud
Browser
Browser
Browser Server
Server
B
![Page 94: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/94.jpg)
Broadcaster Cloud
Browser
Browser
Browser Server
Server
![Page 95: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/95.jpg)
•WebSocketHandler
• Only WebSocket (WARNING)!
•AtmosphereHandler
• All transport
•Jersey Resource
• All transport
•Meteor
• All transport
Atmosphere API
![Page 96: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/96.jpg)
•WebSocketProtocolDefine your own websocket protocol
•SimpleHttpProtocolWebSocket’s message mapped to HTTP POST, avec read/write asynchrone.
•SwaggerSocket: REST over WebSockets -> Powerful Protocol
WebSocket Sub Protocol
![Page 97: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/97.jpg)
Let’s have some fun
![Page 98: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/98.jpg)
https://github.com/Atmosphere/atmosphere/blob/master/samples/
chat/src/main/webapp/jquery/application.js#L1
Single Client to Rule Them All
![Page 99: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/99.jpg)
https://github.com/Atmosphere/atmosphere/blob/master/samples/websocket-chat/src/main/java/org/
atmosphere/samples/chat/WebSocketChat.java#L33
WebSocket
![Page 100: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/100.jpg)
https://github.com/Atmosphere/atmosphere/blob/master/samples/
chat/src/main/java/org/atmosphere/samples/chat/
ChatAtmosphereHandler.java#L33
WebSocket, SSE, long-polling
![Page 101: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/101.jpg)
https://github.com/Atmosphere/atmosphere/blob/master/samples/socketio-chat/src/main/java/org/
atmosphere/samples/chat/SocketIOChatAtmosphereHandler.jav
a#L34
Socket IO
![Page 102: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/102.jpg)
https://github.com/Atmosphere/atmosphere/blob/master/samples/sse-
rest-chat/src/main/java/org/atmosphere/samples/chat/jersey/
ResourceChat.java#L32
Jersey
![Page 103: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/103.jpg)
https://github.com/Atmosphere/atmosphere/blob/master/samples/
jaxrs2-chat/src/main/java/org/atmosphere/samples/chat/jaxrs2/
Jaxrs2Chat.java#L34
JAXRS 2
![Page 104: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/104.jpg)
•REST over WebSocket
•JSON Based
•Simple
•Works with HTTP
•Multi-Request/Response
SwaggerSocket
![Page 105: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/105.jpg)
Join the Revolution
It’s open source, it’s free to jumps in!!
Conclusion
![Page 106: Writing Portable WebSockets in Java](https://reader033.fdocuments.us/reader033/viewer/2022042607/5589e7c0d8b42ad1378b456c/html5/thumbnails/106.jpg)
twitter.com/jfarcand twitter.com/atmo_frameworktwitter.com/swaggersocket
http://github.com/Atmosphere/atmospherehttp://github.com/wordnik/
swaggersocket