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.
Configure the session
From the course: WebSocket Programming with Java EE
Configure the session
- [Instructor] As it stands, we don't have any functionality in our methods, so let's start by adding some logic to the onOpen method. In this method, we want to do several things. Set some session configurations, store the sessions so that later on we can broadcast messages to all clients, and send a welcome message. As you know, the session is created when the connection is opened, and destroyed when the connection is closed, so the onOpen method is a good place to set some configuration values on the session, as it is the first opportunity we get access to the session object. There are a few values we can set, and I will leave you to investigate them yourselves, but the one that is most interesting to us right now is the max idle timeout setting, which specifies the session timeout period. I'm gonna set this value to five minutes. So, we're gonna start with a session object, like so, and we're gonna call one of its set methods. The method we're gonna be calling is setMaxIdleTimeout…
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
-
-
-
-
-
-
WebSocket methodologies1m 52s
-
WebSocket functionality1m 56s
-
Annotation methodology2m 38s
-
Implement WebSocket lifecycles6m 37s
-
Configure the session5m 32s
-
Lifecycle logic4m 1s
-
Programmatic methodology1m 16s
-
WebSocket client API1m 37s
-
Code a client API6m 54s
-
✓ Challenge: Code programmatic endpoint31s
-
✓ Solution: Code programmatic endpoint1m 9s
-
-
-
-
-
-