From the course: WebSocket Programming with Java EE

Unlock the full course today

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

Code a client API

Code a client API

From the course: WebSocket Programming with Java EE

Start my 1-month free trial

Code a client API

- [Instructor] We're going to code the WebSocket client, but before, let's have a look at the code that executes on the server side first. Open up the ChatServer class. I have this class already opened on my screen. This class is where we create the actual WebSocket server. In the main method, you can see that the server is creating by parsing the host name, the port on which we want to listen for WebSocket communications, the route path, which in this case will be WS, and the actual server endpoint class. Once a server has been created, all you need to do to launch it is to call the start method. Now, let's have a look at the server endpoint class. Load up the class ChatServer endpoint. I have it already open on my screen here. You will see that there is absolutely no difference to the server endpoint that we saw earlier on in the course. It is defined by the ServerEndpoint annotation, which accepts the URI endpoint string and the message coders. Lifecycle methods have been defined…

Contents