Every client connection to a WebSocket endpoint has an associated session. This session can be mutated to provide a application and user specific configurations. You canimplement the OnOpen life-cycle stage and configure the session object to store client specific data and to control the sessions timeout. You can implement logic that will maintain the client's state throughout the client/server life-cycle.
- [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…and we're gonna parse it the timeout value,…
Join Alex Theedom as he guides you through the lifecycle of a WebSocket connection, and discusses the Java EE WebSocket programming methodologies: annotation and programmatic. He shows how to secure and encrypt WebSocket endpoints and use simple techniques to test their implementation. In addition, he explains how to integrate the JSON-processing API and build a front-end and server based WebSocket client.
- WebSocket usage
- WebSocket lifecycle and topology
- WebSocket front end and back end
- WebSocket methodologies
- Annotation methodology and programmatic methodology
- Coding a client API
- Using the JSON Processing API
- Coding the encoder and decoder
- Building the front end
- Testing WebSocket endpoints
Skill Level Intermediate
Java Platforms Compared: SE vs EE vs MEwith Peggy Fisher25m 38s Intermediate
1. Introduction to WebSocket
2. WebSockets Front End and Back End
3. Project Application and Structure
4. Java EE WebSocket API
5. Messages and Encoding
6. Build Web Front End
7. WebSocket Security
8. Testing WebSocket Endpoints
Next steps1m 37s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.