Interface Session

All Superinterfaces:
AutoCloseable, Closeable

public interface Session extends Closeable
A Web Socket session represents a conversation between two web socket endpoints. As soon as the websocket handshake completes successfully, the web socket implementation provides the endpoint an open websocket session. The endpoint can then register interest in incoming messages that are part of this newly created session by providing a MessageHandler to the session, and can send messages to the other end of the conversation by means of the RemoteEndpoint object obtained from this session.

Once the session is closed, it is no longer valid for use by applications. Calling any of its methods (with the exception of the close() methods) once the session has been closed will result in an IllegalStateException being thrown. Developers should retrieve any information from the session during the Endpoint.onClose(jakarta.websocket.Session, jakarta.websocket.CloseReason) method. Following the convention of Closeable calling the Session close() methods after the Session has been closed has no effect.

Session objects may be called by multiple threads. Implementations must ensure the integrity of the mutable properties of the session under such circumstances.