From the course: WebSocket Programming with Java EE

Unlock the full course today

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

✓ Solution: Code programmatic endpoint

✓ Solution: Code programmatic endpoint

From the course: WebSocket Programming with Java EE

Start my 1-month free trial

✓ Solution: Code programmatic endpoint

- [Instructor] So how do you get on? Well here's my solution. Let's start with the application configuration class. Now, firstly you must implement the interface server application config. And in the method, get endpoint configs I have created two lists, one for the encoder class and one for the decoder class, which I then add to the construction of the endpoint. Now this is where I create the endpoint and associate the class that handles the WebSocket lifecycle and the URI. So now let's take a look at the chat server endpoint class. The first thing you need to do is to extend the endpoint class and then implement the only abstract method on open. Let's go down and have a look at the method on open. In the on open method is where the magic happens. First I add the message handler to the session object. For simplicity, I have only added logic that prints the message out to a log file. Then I obtain the ring directly from the session by calling the get path parameter method. And then I…

Contents