SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
JEE - WebSockets
Fahad R. Golra
ECE Paris Ecole d'Ingénieurs - FRANCE
Lecture 6 - WebSockets
• Web communications technologies
• Web Socket methodology
• Web Socket APIs
• JavaScript API
• Java API for WebSockets
2 JEE - WebSockets
Interactions over HTTP
• It is half-duplex
• It is verbose
• Server push issue
• Frequent Polling
• Long Polling
• Chunked Encoding
• Applet & Flash
3 JEE - WebSockets
Frequent polling
4
Long Polling
5
Chunked Encoding
6 JEE - WebSockets
Applets & Adobe Flash
7
Interactions through WebSockets
• It is TCP-based
• Supports bi-directional, full-duplex messaging
• Two phases
• Handshake
• Data Transfer
8 JEE - WebSockets
Handshake
9 JEE - WebSockets
client Server
• Agreeing on upgrade to WebSocket
• No response means no handshake
Handshake Request (over HTTP)
Handshake Response (over HTTP)
WebSocket Upgrade Request
GET /webSocketEndpoint HTTP/1.1
Host: www.ece.fr
Connection: Upgrade
Upgrade: websocket
Origin: http://ece.fr
Sec-WebSocket-Key: s3JKEMbDL4ErLkh9GBlXDx==
Sec-WebSocket-Version: 13
Sec-WebSocket-Protocol: chat
HTTP/1.1 101 Switching Protocols
Server: Apache 2.4
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Sec-WebSocket-Protocol: chat
10
client key
hashed value
Server
Establishing a connection
• Once connected both client and server become peers
with equal rights for interaction and closing the
session.
11 JEE - WebSockets
client Server
Handshake Request (over HTTP)
Handshake Response (over HTTP)
Connected
Full-duplex WebSocket Communications
12 JEE - WebSockets
client Server
message
Connected
message
message
message
message
message
Disconnected
close
Where is it used?
• Chat
• Online games
• Live stock/News tickers
• HD Video Streaming
• Bulk transactional data transfer
• Real time monitoring for remote systems
13 JEE - WebSockets
WebSocket Interface in API
14
APIs for WebSocket
• Javascript API
• Client Only
var connection = new WebSocket(uri);
• JEE
• Client API
• foundational API for data transfer
• Server API
• additional constructs for managing handshakes,
server endpoints, server container, etc.
15 JEE - WebSockets
Javascript API - readyState Attribute
• CONNECTING (numeric value 0)
• When object is created. The connection has not yet established.
• OPEN (numeric value 1)
• The WebSocket connection is established and communication is
possible.
• CLOSING (numeric value 2)
• The connection is going through the closing handshake, or the
close() method has been invoked.
• CLOSED (numeric value 3)
• The connection has been closed or could not be opened.
if(connection.readyState == WebSocket.OPEN) {
/* do something */ }
16 JEE - WebSockets
Javascript API - events
connection.onopen = function(event) { }
• readyState changes from CONNECTING to OPEN
connection.onclose = function(event) { }
• readyState changes from CLOSING to CLOSED
connection.onerror = function(event) { }
• In case of client-side errors
connection.onmessage = function(event) { }
• On arrival of a message
17 JEE - WebSockets
JavaScriptAPI - onmessage()
• It has a data property
• String: message = text
• Blob: message = binary, binaryType = “blob”
• ArrayBuffer: message = binary, binaryType = “arraybuffer”
• binaryType is a property of web socket
var socket = new WebSocket(“ws://localhost:8080/BasicWebSocketExample/
echo");
socket.onmessage = function(event){
if(event.data instanceof Blob){
console.log("Blob message received", event.data);
var blob = new Blob(event.data);
}
}
18 JEE - WebSockets
Javascript API - Other methods
• close()
• optional code & optional reason string
• send()
• accepts string, blob, ArrayBuffer, ArraryBufferView
connection.onopen = function() {
var intervalId = window.setInterval(function() {
if(connection.readyState != WebSocket.OPEN) {
window.clearInterval(intervalId);
return;
}
if(connection.bufferedAmount == 0)
connection.send(updatedModelData);
}, 50);
}
19 JEE - WebSockets
Simple Example - Client side
• Used the wildfly archetype used in last TP
wildfly-javaee7-webapp-blank-archetype
• POM (added dependencies)
<dependency>
<groupId>org.jboss.spec.javax.websocket</groupId>
<artifactId>jboss-websocket-api_1.0_spec</artifactId>
<scope>provided</scope>
</dependency>
20
Simple Example - Client side
<!DOCTYPE html>
<html><head>
<meta charset="UTF-8">
<title>Echo WebSocket</title>
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:8080/BasicWebSocketExample/
echo");
//Event handler for the WebSocket connection opening
socket.onopen = function(event) {
console.log("Connection open...");};
//Event handler for closed connections
socket.onclose = function(event) {
console.log("Connection closed", event);};
//Event handler for errors in the WebSocket object
socket.onerror = function(event) {
console.log("WebSocket Error: " , event);};
21
Simple Example - Client side
//Event handler for the WebSocket message reception
socket.onmessage = function(event){
alert(event.data)
if(typeof event.data === "string"){
console.log("String message received", event, event.data);
} else {
console.log("Other message received", event, event.data);
}
}
</script>
</head>
<body>
<button onclick='socket.send("hey dude")'>send</button>
</body>
</html>
Note: Server side in the coming slides ….
22
JEE Client API - The Process
• The process for creating and deploying a WebSocket
endpoint follows.
• Create an endpoint class.
• Implement the lifecycle methods of the endpoint.
• Add your business logic to the endpoint.
• Deploy the endpoint inside a web application.
• Two ways to create endpoints
• Programmatic endpoints
• Annotated endpoints
23 JEE - WebSockets
Programmatic Endpoints
• Endpoint is created by extending Endpoint class
• Three methods to override
• onOpen, onClose and onError
• onOpen is an abstract method (must implement)
• onOpen has session parameter which is
responsible for communication
• getBasicRemote give the remote end
• addMessageHandler method of the session parameter
is used to register message handlers
• message handler is implemented as anonymous class
24 JEE - WebSockets
Programmatic Endpoints
package com.ece.jee;
public class EchoEndPoint extends Endpoint {
@Override
public void onOpen(final Session session, EndpointConfig config) {
session.addMessageHandler(new MessageHandler.Whole<String>() {
@Override
public void onMessage(String msg) {
try {
session.getBasicRemote().sendText(msg);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}
25
Annotated Endpoints
• Deployment is easy through annotations
• Annotations mark the respective methods for each
event in the lifecycle
• onOpen
• onMessage
• onError
• onClose
26 JEE - WebSockets
Endpoint Lifecycle Annotations
27
Annotation Event Example
onOpen Connection
opened
@OnOpen
public void open(Session session,
EndpointConfig conf) { }
onMessage Message
received
@OnMessage
public void message(Session session,
String msg) { }
onError Connection
error
@OnError
public void error(Session session,
Throwable error) { }
onClose Connection
closed
@OnClose
public void close(Session session,
CloseReason reason) { }
Sending Messages
• Get session object from the annotated methods
• Get the remoteEndPoint object (either of two)
Session.getBasicRemote
Session.getAsyncRemote
• Send messages
void RemoteEndpoint.Basic.sendText(String text)
void RemoteEndpoint.Basic.sendBinary(ByteBuffer data)
void RemoteEndpoint.sendPing(ByteBuffer appData)
void RemoteEndpoint.sendPong(ByteBuffer appData)
28 JEE - WebSockets
Simple Example - (cntd) Server Side
@ServerEndpoint("/echo")
public class Echo {
private Session session;
@OnOpen
public void connect(Session session) {
this.session = session;
System.out.println("session opened: " + session);
}
@OnClose
public void close() {
this.session = null;
System.out.println("session closed: " + session);
}
@OnMessage
public void onMessage(String msg) {
System.out.println("on message is called");
this.session.getAsyncRemote().sendText("Message from Server:" + msg);
}
}
29
Sending message to all endpoints
@ServerEndpoint("/echoAll")
public class EchoAllEndPoint {
@OnMessage
public void onMessage(Session session, String msg) {
try {
for (Session sess : session.getOpenSessions()) {
if (sess.isOpen())
sess.getBasicRemote().sendText(msg);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
30 JEE - WebSockets
Receiving messages
• onMessage annotations are used to handle incoming
messages
• At most three methods with this annotation are
allowed
• text
• binary
• pong
31 JEE - WebSockets
Receiving messages
@ServerEndpoint("/receive")
public class ReceiveEndPoint {
@OnMessage
public void textMessage(Session session, String msg) {
System.out.println("Text message: " + msg);
}
@OnMessage
public void binaryMessage(Session session, ByteBuffer msg) {
System.out.println("Binary message: " + msg.toString());
}
@OnMessage
public void pongMessage(Session session, PongMessage msg) {
System.out.println("Pong message: "
+ msg.getApplicationData().toString());
}
}
32
33 JEE - WebSockets

Contenu connexe

Tendances

Tendances (17)

JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 update
 
Struts 2 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
JAX-WS Basics
JAX-WS BasicsJAX-WS Basics
JAX-WS Basics
 
JSP - Part 1
JSP - Part 1JSP - Part 1
JSP - Part 1
 
Java Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVCJava Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVC
 
Data Access with JDBC
Data Access with JDBCData Access with JDBC
Data Access with JDBC
 
JDBC in Servlets
JDBC in ServletsJDBC in Servlets
JDBC in Servlets
 
Spring - Part 4 - Spring MVC
Spring - Part 4 - Spring MVCSpring - Part 4 - Spring MVC
Spring - Part 4 - Spring MVC
 
JDBC
JDBCJDBC
JDBC
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Spring & hibernate
Spring & hibernateSpring & hibernate
Spring & hibernate
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server Page
 

En vedette

Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: ServletsFahad Golra
 
Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Fahad Golra
 
Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)Fahad Golra
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RSFahad Golra
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEEFahad Golra
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)Fahad Golra
 
Tutorial 4 - Basics of Digital Photography
Tutorial 4 - Basics of Digital PhotographyTutorial 4 - Basics of Digital Photography
Tutorial 4 - Basics of Digital PhotographyFahad Golra
 
TNAPS 3 Installation
TNAPS 3 InstallationTNAPS 3 Installation
TNAPS 3 Installationtncor
 
Ejb in java. part 1.
Ejb in java. part 1.Ejb in java. part 1.
Ejb in java. part 1.Asya Dudnik
 
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!Омские ИТ-субботники
 
Apache Lucene + Hibernate = Hibernate Search
Apache Lucene + Hibernate = Hibernate SearchApache Lucene + Hibernate = Hibernate Search
Apache Lucene + Hibernate = Hibernate SearchVitebsk Miniq
 
JMS Introduction
JMS IntroductionJMS Introduction
JMS IntroductionAlex Su
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 
The Modern Java Web Developer Bootcamp - Devoxx 2013
The Modern Java Web Developer Bootcamp - Devoxx 2013The Modern Java Web Developer Bootcamp - Devoxx 2013
The Modern Java Web Developer Bootcamp - Devoxx 2013Matt Raible
 
Introduction to WebSockets
Introduction to WebSocketsIntroduction to WebSockets
Introduction to WebSocketsGunnar Hillert
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJBPeter R. Egli
 
JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging ServicePeter R. Egli
 

En vedette (20)

Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: Servlets
 
Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2
 
Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEE
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)
 
Tutorial 4 - Basics of Digital Photography
Tutorial 4 - Basics of Digital PhotographyTutorial 4 - Basics of Digital Photography
Tutorial 4 - Basics of Digital Photography
 
TNAPS 3 Installation
TNAPS 3 InstallationTNAPS 3 Installation
TNAPS 3 Installation
 
Ejb in java. part 1.
Ejb in java. part 1.Ejb in java. part 1.
Ejb in java. part 1.
 
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
 
Apache Lucene + Hibernate = Hibernate Search
Apache Lucene + Hibernate = Hibernate SearchApache Lucene + Hibernate = Hibernate Search
Apache Lucene + Hibernate = Hibernate Search
 
JMS Introduction
JMS IntroductionJMS Introduction
JMS Introduction
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
The Modern Java Web Developer Bootcamp - Devoxx 2013
The Modern Java Web Developer Bootcamp - Devoxx 2013The Modern Java Web Developer Bootcamp - Devoxx 2013
The Modern Java Web Developer Bootcamp - Devoxx 2013
 
Introduction to WebSockets
Introduction to WebSocketsIntroduction to WebSockets
Introduction to WebSockets
 
The HTML5 WebSocket API
The HTML5 WebSocket APIThe HTML5 WebSocket API
The HTML5 WebSocket API
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
 
EJB .
EJB .EJB .
EJB .
 
JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging Service
 
Domain object model
Domain object modelDomain object model
Domain object model
 

Similaire à Lecture 6 Web Sockets

Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSocketsGonzalo Ayuso
 
Enhancing Mobile User Experience with WebSocket
Enhancing Mobile User Experience with WebSocketEnhancing Mobile User Experience with WebSocket
Enhancing Mobile User Experience with WebSocketMauricio "Maltron" Leal
 
HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014Christian Wenz
 
vlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentationvlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets PresentationVolodymyr Lavrynovych
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersViktor Gamov
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serializationGWTcon
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaJames Falkner
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EEAlexis Hassler
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsYakov Fain
 
Unity and WebSockets
Unity and WebSocketsUnity and WebSockets
Unity and WebSocketsJosh Glover
 
Websockets - DevFestX May 19, 2012
Websockets - DevFestX May 19, 2012Websockets - DevFestX May 19, 2012
Websockets - DevFestX May 19, 2012Sameer Segal
 
Pushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax WPushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax Wrajivmordani
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 

Similaire à Lecture 6 Web Sockets (20)

Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
Enhancing Mobile User Experience with WebSocket
Enhancing Mobile User Experience with WebSocketEnhancing Mobile User Experience with WebSocket
Enhancing Mobile User Experience with WebSocket
 
HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014
 
vlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentationvlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentation
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
 
Html5 websockets
Html5 websocketsHtml5 websockets
Html5 websockets
 
Web sockets in Java
Web sockets in JavaWeb sockets in Java
Web sockets in Java
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
WebSockets in JEE 7
WebSockets in JEE 7WebSockets in JEE 7
WebSockets in JEE 7
 
ITI006En-AJAX
ITI006En-AJAXITI006En-AJAX
ITI006En-AJAX
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and Java
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSockets
 
Socket.io
Socket.ioSocket.io
Socket.io
 
Unity and WebSockets
Unity and WebSocketsUnity and WebSockets
Unity and WebSockets
 
Websockets - DevFestX May 19, 2012
Websockets - DevFestX May 19, 2012Websockets - DevFestX May 19, 2012
Websockets - DevFestX May 19, 2012
 
Pushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax WPushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax W
 
Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 

Plus de Fahad Golra

Seance 4- Programmation en langage C
Seance 4- Programmation en langage CSeance 4- Programmation en langage C
Seance 4- Programmation en langage CFahad Golra
 
Seance 3- Programmation en langage C
Seance 3- Programmation en langage C Seance 3- Programmation en langage C
Seance 3- Programmation en langage C Fahad Golra
 
Seance 2 - Programmation en langage C
Seance 2 - Programmation en langage CSeance 2 - Programmation en langage C
Seance 2 - Programmation en langage CFahad Golra
 
Seance 1 - Programmation en langage C
Seance 1 - Programmation en langage CSeance 1 - Programmation en langage C
Seance 1 - Programmation en langage CFahad Golra
 
Tutorial 3 - Basics of Digital Photography
Tutorial 3 - Basics of Digital PhotographyTutorial 3 - Basics of Digital Photography
Tutorial 3 - Basics of Digital PhotographyFahad Golra
 
Tutorial 2 - Basics of Digital Photography
Tutorial 2 - Basics of Digital PhotographyTutorial 2 - Basics of Digital Photography
Tutorial 2 - Basics of Digital PhotographyFahad Golra
 
Tutorial 1 - Basics of Digital Photography
Tutorial 1 - Basics of Digital PhotographyTutorial 1 - Basics of Digital Photography
Tutorial 1 - Basics of Digital PhotographyFahad Golra
 
Deviation Detection in Process Enactment
Deviation Detection in Process EnactmentDeviation Detection in Process Enactment
Deviation Detection in Process EnactmentFahad Golra
 
Meta l metacase tools & possibilities
Meta l metacase tools & possibilitiesMeta l metacase tools & possibilities
Meta l metacase tools & possibilitiesFahad Golra
 

Plus de Fahad Golra (9)

Seance 4- Programmation en langage C
Seance 4- Programmation en langage CSeance 4- Programmation en langage C
Seance 4- Programmation en langage C
 
Seance 3- Programmation en langage C
Seance 3- Programmation en langage C Seance 3- Programmation en langage C
Seance 3- Programmation en langage C
 
Seance 2 - Programmation en langage C
Seance 2 - Programmation en langage CSeance 2 - Programmation en langage C
Seance 2 - Programmation en langage C
 
Seance 1 - Programmation en langage C
Seance 1 - Programmation en langage CSeance 1 - Programmation en langage C
Seance 1 - Programmation en langage C
 
Tutorial 3 - Basics of Digital Photography
Tutorial 3 - Basics of Digital PhotographyTutorial 3 - Basics of Digital Photography
Tutorial 3 - Basics of Digital Photography
 
Tutorial 2 - Basics of Digital Photography
Tutorial 2 - Basics of Digital PhotographyTutorial 2 - Basics of Digital Photography
Tutorial 2 - Basics of Digital Photography
 
Tutorial 1 - Basics of Digital Photography
Tutorial 1 - Basics of Digital PhotographyTutorial 1 - Basics of Digital Photography
Tutorial 1 - Basics of Digital Photography
 
Deviation Detection in Process Enactment
Deviation Detection in Process EnactmentDeviation Detection in Process Enactment
Deviation Detection in Process Enactment
 
Meta l metacase tools & possibilities
Meta l metacase tools & possibilitiesMeta l metacase tools & possibilities
Meta l metacase tools & possibilities
 

Dernier

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
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...Shane Coughlan
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
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 SoftwareJim McKeeth
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
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 🔝✔️✔️Delhi Call girls
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
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 🔝✔️✔️Delhi Call girls
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%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 Bahrainmasabamasaba
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
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-...Steffen Staab
 

Dernier (20)

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
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...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
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
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
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 🔝✔️✔️
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
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 🔝✔️✔️
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%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
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
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-...
 

Lecture 6 Web Sockets

  • 1. JEE - WebSockets Fahad R. Golra ECE Paris Ecole d'Ingénieurs - FRANCE
  • 2. Lecture 6 - WebSockets • Web communications technologies • Web Socket methodology • Web Socket APIs • JavaScript API • Java API for WebSockets 2 JEE - WebSockets
  • 3. Interactions over HTTP • It is half-duplex • It is verbose • Server push issue • Frequent Polling • Long Polling • Chunked Encoding • Applet & Flash 3 JEE - WebSockets
  • 6. Chunked Encoding 6 JEE - WebSockets
  • 7. Applets & Adobe Flash 7
  • 8. Interactions through WebSockets • It is TCP-based • Supports bi-directional, full-duplex messaging • Two phases • Handshake • Data Transfer 8 JEE - WebSockets
  • 9. Handshake 9 JEE - WebSockets client Server • Agreeing on upgrade to WebSocket • No response means no handshake Handshake Request (over HTTP) Handshake Response (over HTTP)
  • 10. WebSocket Upgrade Request GET /webSocketEndpoint HTTP/1.1 Host: www.ece.fr Connection: Upgrade Upgrade: websocket Origin: http://ece.fr Sec-WebSocket-Key: s3JKEMbDL4ErLkh9GBlXDx== Sec-WebSocket-Version: 13 Sec-WebSocket-Protocol: chat HTTP/1.1 101 Switching Protocols Server: Apache 2.4 Connection: Upgrade Upgrade: websocket Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk= Sec-WebSocket-Protocol: chat 10 client key hashed value Server
  • 11. Establishing a connection • Once connected both client and server become peers with equal rights for interaction and closing the session. 11 JEE - WebSockets client Server Handshake Request (over HTTP) Handshake Response (over HTTP) Connected
  • 12. Full-duplex WebSocket Communications 12 JEE - WebSockets client Server message Connected message message message message message Disconnected close
  • 13. Where is it used? • Chat • Online games • Live stock/News tickers • HD Video Streaming • Bulk transactional data transfer • Real time monitoring for remote systems 13 JEE - WebSockets
  • 15. APIs for WebSocket • Javascript API • Client Only var connection = new WebSocket(uri); • JEE • Client API • foundational API for data transfer • Server API • additional constructs for managing handshakes, server endpoints, server container, etc. 15 JEE - WebSockets
  • 16. Javascript API - readyState Attribute • CONNECTING (numeric value 0) • When object is created. The connection has not yet established. • OPEN (numeric value 1) • The WebSocket connection is established and communication is possible. • CLOSING (numeric value 2) • The connection is going through the closing handshake, or the close() method has been invoked. • CLOSED (numeric value 3) • The connection has been closed or could not be opened. if(connection.readyState == WebSocket.OPEN) { /* do something */ } 16 JEE - WebSockets
  • 17. Javascript API - events connection.onopen = function(event) { } • readyState changes from CONNECTING to OPEN connection.onclose = function(event) { } • readyState changes from CLOSING to CLOSED connection.onerror = function(event) { } • In case of client-side errors connection.onmessage = function(event) { } • On arrival of a message 17 JEE - WebSockets
  • 18. JavaScriptAPI - onmessage() • It has a data property • String: message = text • Blob: message = binary, binaryType = “blob” • ArrayBuffer: message = binary, binaryType = “arraybuffer” • binaryType is a property of web socket var socket = new WebSocket(“ws://localhost:8080/BasicWebSocketExample/ echo"); socket.onmessage = function(event){ if(event.data instanceof Blob){ console.log("Blob message received", event.data); var blob = new Blob(event.data); } } 18 JEE - WebSockets
  • 19. Javascript API - Other methods • close() • optional code & optional reason string • send() • accepts string, blob, ArrayBuffer, ArraryBufferView connection.onopen = function() { var intervalId = window.setInterval(function() { if(connection.readyState != WebSocket.OPEN) { window.clearInterval(intervalId); return; } if(connection.bufferedAmount == 0) connection.send(updatedModelData); }, 50); } 19 JEE - WebSockets
  • 20. Simple Example - Client side • Used the wildfly archetype used in last TP wildfly-javaee7-webapp-blank-archetype • POM (added dependencies) <dependency> <groupId>org.jboss.spec.javax.websocket</groupId> <artifactId>jboss-websocket-api_1.0_spec</artifactId> <scope>provided</scope> </dependency> 20
  • 21. Simple Example - Client side <!DOCTYPE html> <html><head> <meta charset="UTF-8"> <title>Echo WebSocket</title> <script type="text/javascript"> var socket = new WebSocket("ws://localhost:8080/BasicWebSocketExample/ echo"); //Event handler for the WebSocket connection opening socket.onopen = function(event) { console.log("Connection open...");}; //Event handler for closed connections socket.onclose = function(event) { console.log("Connection closed", event);}; //Event handler for errors in the WebSocket object socket.onerror = function(event) { console.log("WebSocket Error: " , event);}; 21
  • 22. Simple Example - Client side //Event handler for the WebSocket message reception socket.onmessage = function(event){ alert(event.data) if(typeof event.data === "string"){ console.log("String message received", event, event.data); } else { console.log("Other message received", event, event.data); } } </script> </head> <body> <button onclick='socket.send("hey dude")'>send</button> </body> </html> Note: Server side in the coming slides …. 22
  • 23. JEE Client API - The Process • The process for creating and deploying a WebSocket endpoint follows. • Create an endpoint class. • Implement the lifecycle methods of the endpoint. • Add your business logic to the endpoint. • Deploy the endpoint inside a web application. • Two ways to create endpoints • Programmatic endpoints • Annotated endpoints 23 JEE - WebSockets
  • 24. Programmatic Endpoints • Endpoint is created by extending Endpoint class • Three methods to override • onOpen, onClose and onError • onOpen is an abstract method (must implement) • onOpen has session parameter which is responsible for communication • getBasicRemote give the remote end • addMessageHandler method of the session parameter is used to register message handlers • message handler is implemented as anonymous class 24 JEE - WebSockets
  • 25. Programmatic Endpoints package com.ece.jee; public class EchoEndPoint extends Endpoint { @Override public void onOpen(final Session session, EndpointConfig config) { session.addMessageHandler(new MessageHandler.Whole<String>() { @Override public void onMessage(String msg) { try { session.getBasicRemote().sendText(msg); } catch (IOException e) { e.printStackTrace(); } } }); } } 25
  • 26. Annotated Endpoints • Deployment is easy through annotations • Annotations mark the respective methods for each event in the lifecycle • onOpen • onMessage • onError • onClose 26 JEE - WebSockets
  • 27. Endpoint Lifecycle Annotations 27 Annotation Event Example onOpen Connection opened @OnOpen public void open(Session session, EndpointConfig conf) { } onMessage Message received @OnMessage public void message(Session session, String msg) { } onError Connection error @OnError public void error(Session session, Throwable error) { } onClose Connection closed @OnClose public void close(Session session, CloseReason reason) { }
  • 28. Sending Messages • Get session object from the annotated methods • Get the remoteEndPoint object (either of two) Session.getBasicRemote Session.getAsyncRemote • Send messages void RemoteEndpoint.Basic.sendText(String text) void RemoteEndpoint.Basic.sendBinary(ByteBuffer data) void RemoteEndpoint.sendPing(ByteBuffer appData) void RemoteEndpoint.sendPong(ByteBuffer appData) 28 JEE - WebSockets
  • 29. Simple Example - (cntd) Server Side @ServerEndpoint("/echo") public class Echo { private Session session; @OnOpen public void connect(Session session) { this.session = session; System.out.println("session opened: " + session); } @OnClose public void close() { this.session = null; System.out.println("session closed: " + session); } @OnMessage public void onMessage(String msg) { System.out.println("on message is called"); this.session.getAsyncRemote().sendText("Message from Server:" + msg); } } 29
  • 30. Sending message to all endpoints @ServerEndpoint("/echoAll") public class EchoAllEndPoint { @OnMessage public void onMessage(Session session, String msg) { try { for (Session sess : session.getOpenSessions()) { if (sess.isOpen()) sess.getBasicRemote().sendText(msg); } } catch (IOException e) { e.printStackTrace(); } } } 30 JEE - WebSockets
  • 31. Receiving messages • onMessage annotations are used to handle incoming messages • At most three methods with this annotation are allowed • text • binary • pong 31 JEE - WebSockets
  • 32. Receiving messages @ServerEndpoint("/receive") public class ReceiveEndPoint { @OnMessage public void textMessage(Session session, String msg) { System.out.println("Text message: " + msg); } @OnMessage public void binaryMessage(Session session, ByteBuffer msg) { System.out.println("Binary message: " + msg.toString()); } @OnMessage public void pongMessage(Session session, PongMessage msg) { System.out.println("Pong message: " + msg.getApplicationData().toString()); } } 32
  • 33. 33 JEE - WebSockets