It2EDU

Wednesday, January 25, 2017

WEB SOCKET







                                                                                               


Web socket are introduced in java EE7 JSR 356 is related to web
socket and provides API for creating web socket applications. Web socket is an
application protocol that for a ideas full-duplex communication between two peers
over the TCP protocol. The web socket enables web applications to deliver a
richer user experience.


In web socket   application a web socket end point published
by the server, and the client uses the End points URI to connect to the server.
When the connection is Established Web socket protocol is symmetrical and the
client & server can send messages to Each other when the connection is
open, and they can close the connection at any time. Clients usually connect
only to one server, and servers accept connections from multiple clients.


Web socket protocol has two parts


1) Hand shake


2) Data transfer


Client initiates the hand shake by sending a request to a
web socket end point using its URI. It is comfortable with HTTP-based
infrastructure. The web socket client API specified in JSR356 also enables you
to access remote web socket end points from any JAVA applications.


           Javax.websocket.
Server.


           Javax.Websocket.Endpoint


The java API for web socket enables you to create two kinds
of end points


1.      
Programmatic 
end point


2.      
Annotated end point


Creation of programmatic end point:


End points are instance of endpoint class. This is in the
part of web socket. To create a programmatic end point you extend the Endpoint
class and override its life cycle methods.


To create an annotated end point: By using annotations creating
annotation based end points are created.


After successfully create endpoint deploy these code into a
specific URI in the application.


 So that remote
clients can connect to it.


Steps to create& deploy web socket end point.


1) Create end point class.


2) Implement life cycle methods of the end point.


3) Add business logic to end point.


4)Deploy the end point inside a web application.


 








0 comments:

Post a Comment