O'Reilly logo

Developing RESTful Services with JAX-RS 2.0, WebSockets, and JSON by Bhakti Mehta, Masoud Kalali

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Java WebSocket Client API

Chapter 2, WebSockets and Server-sent Events, covered the Java WebSockets client API. Any POJO can be transformed into a WebSockets client by annotating it with @ClientEndpoint.

Additionally the user can add encoders and decoders attributes to the @ClientEndpoint annotation to encode application objects into WebSockets messages and WebSockets messages into application objects.

The following table shows the @ClientEndpoint annotation and its attributes:

Annotation

Attribute

Description

@ClientEndpoint

 

This class-level annotation signifies that the Java class is a WebSockets client that will connect to a WebSockets server endpoint.

 

value

The value is the URI with a leading /.

 

encoders

Contains a list ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required