From the course: WebSocket Programming with Java EE
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Annotation methodology
From the course: WebSocket Programming with Java EE
Annotation methodology
- [Instructor] Annotations are used to define endpoints and lifecycle methods, and are arguably the easiest way to construct WebSocket endpoints. Okay, let's dive into the annotation way of defining WebSocket endpoints. All configurations are made in the same class, and it's the same class that defines the lifecycle methods. Configuration is done by passing metadata to the annotations, and this, as you'll see later on, is quite different to it's implementation of the programmatic method. So, the specify that a class represents an endpoint, we annotate the class at server endpoint, and pass it the URI of it's endpoint location. In this case, the endpoint location is chat, and we annotate four methods that will handle the WebSocket lifecycle on open, on message, on close, and on error. Each of the four lifecycle methods accepts at least the session as a parameter, and the OnMessage method accepts a message object that contains the message received. Remember that we touched on the…
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)
-
-
-
-
-