From the course: WebSocket Programming with Java EE

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

WebSocket client API

WebSocket client API

From the course: WebSocket Programming with Java EE

Start my 1-month free trial

WebSocket client API

- [Instructor] The WebSocket Protocol offers full, duplex communication and for this to be possible there must be a Client and a server. The server endpoint is developed in Java and hazard on the server. And often the client is a webpage, usually implemented in JavaScript and HTML5. However, this does not have to be the case. We can develop a client in Java and by doing so we can let two machines communicate with each other. Let's take a look at the client API that the Java API for WebSocket provides and see how to use it to develop a very lightweight chat application. The Client requires a minimum of two parts. The Client endpoint that handles the messages and the Client manager that makes a connection to the server endpoint. The Client endpoint is defined by annotating a class Client endpoint and passing it configurations for message encoding and decoding. The other part is ClientManager which connects and manages the Client lifecycle. For this we're going to use an instance of the…

Contents