Class HeartbeatHandler
java.lang.Object
com.vaadin.flow.server.SynchronizedRequestHandler
com.vaadin.flow.server.communication.HeartbeatHandler
- All Implemented Interfaces:
RequestHandler,SessionExpiredHandler,Serializable
Handles heartbeat requests. Heartbeat requests are periodically sent by the
client-side to inform the server that the UI sending the heartbeat is still
alive (the browser window is open, the connection is up) even when there are
no UIDL requests for a prolonged period of time. UIs that do not receive
either heartbeat or UIDL requests are eventually removed from the session and
garbage collected.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
SynchronizedRequestHandler.ResponseWriter -
Field Summary
Fields inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
MAX_BUFFER_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanHandleRequest(VaadinRequest request) Check whether a request may be handled by this handler.booleanhandleSessionExpired(VaadinRequest request, VaadinResponse response) Called when the a session expiration has occurred and a notification needs to be sent to the user.booleansynchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) Handles a heartbeat request for the given session.Methods inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
getRequestBody, handleRequest, isReadAndWriteOutsideSessionLock, synchronizedHandleRequestMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.server.RequestHandler
handleRequest
-
Constructor Details
-
HeartbeatHandler
public HeartbeatHandler()
-
-
Method Details
-
canHandleRequest
Description copied from class:SynchronizedRequestHandlerCheck whether a request may be handled by this handler. This can be used as an optimization to avoid locking the session just to investigate some method property. The default implementation just returnstruewhich means that all requests will be handled by callingSynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse)with the session locked.- Overrides:
canHandleRequestin classSynchronizedRequestHandler- Parameters:
request- the request to handle- Returns:
trueif the request handling should continue once the session has been locked;falseif there's no need to lock the session since the request would still not be handled.
-
synchronizedHandleRequest
public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException Handles a heartbeat request for the given session. Reads the GET parameter namedApplicationConstants.UI_ID_PARAMETERto identify the UI. If the UI is found in the session, sets itheartbeat timestampto the current time. Otherwise, writes a HTTP Not Found error to the response.- Specified by:
synchronizedHandleRequestin classSynchronizedRequestHandler- Parameters:
session- The session for the requestrequest- The request to handleresponse- The response object to which a response can be written.- Returns:
- true if a response has been written and no further request handlers should be called, otherwise false
- Throws:
IOException- If an IO error occurred- See Also:
-
handleSessionExpired
public boolean handleSessionExpired(VaadinRequest request, VaadinResponse response) throws IOException Description copied from interface:SessionExpiredHandlerCalled when the a session expiration has occurred and a notification needs to be sent to the user. If a response is written, this method should returntrueto indicate that no moreSessionExpiredHandlerhandlers should be invoked for the request.- Specified by:
handleSessionExpiredin interfaceSessionExpiredHandler- Parameters:
request- The request to handleresponse- The response object to which a response can be written.- Returns:
- true if a response has been written and no further request handlers should be called, otherwise false
- Throws:
IOException- If an IO error occurred
-