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

Configure the session

From the course: WebSocket Programming with Java EE

Start my 1-month free trial

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…

Contents