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.
✓ Solution: Code programmatic endpoint
From the course: WebSocket Programming with Java EE
✓ 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
WebSocket methodologies1m 52s
-
(Locked)
WebSocket functionality1m 56s
-
(Locked)
Annotation methodology2m 38s
-
Implement WebSocket lifecycles6m 37s
-
(Locked)
Configure the session5m 32s
-
(Locked)
Lifecycle logic4m 1s
-
(Locked)
Programmatic methodology1m 16s
-
(Locked)
WebSocket client API1m 37s
-
(Locked)
Code a client API6m 54s
-
(Locked)
✓ Challenge: Code programmatic endpoint31s
-
(Locked)
✓ Solution: Code programmatic endpoint1m 9s
-
(Locked)
-
-
-
-
-