Ether Framework
Unified API docs for Ether modules
Loading...
Searching...
No Matches
dev.rafex.ether.websocket.jetty12.JettyWebSocketSession Class Reference

Jetty 12 implementation of WebSocketSession. More...

Inheritance diagram for dev.rafex.ether.websocket.jetty12.JettyWebSocketSession:
Collaboration diagram for dev.rafex.ether.websocket.jetty12.JettyWebSocketSession:

Public Member Functions

Object attribute (final String name)
 Returns a session-scoped attribute by name.
void attribute (final String name, final Object value)
 Sets or removes a session-scoped attribute.
CompletionStage< Void > close (final WebSocketCloseStatus status)
 Closes the session with the given status code and reason.
String headerFirst (final String name)
 Returns the first value of an HTTP header.
Map< String, List< String > > headers ()
 Returns an unmodifiable view of all HTTP headers.
String id ()
 Returns a unique session identifier derived from the native session's identity hash code.
boolean isOpen ()
 Returns whether the underlying session is still open.
 JettyWebSocketSession (final Session session, final String path, final Map< String, String > pathParams, final Map< String, List< String > > queryParams, final Map< String, List< String > > headers)
 Creates a session wrapper.
String path ()
 Returns the matched request path.
String pathParam (final String name)
 Returns the value of a single path parameter by name.
Map< String, String > pathParams ()
 Returns an unmodifiable view of all path parameters.
List< String > queryAll (final String name)
 Returns all values of a query parameter.
String queryFirst (final String name)
 Returns the first value of a query parameter.
Map< String, List< String > > queryParams ()
 Returns an unmodifiable view of all query parameters.
CompletionStage< Void > sendBinary (final ByteBuffer data)
 Sends a binary message asynchronously.
CompletionStage< Void > sendText (final String text)
 Sends a text message asynchronously.
String subprotocol ()
 Returns the accepted subprotocol, or an empty string if none was negotiated.

Detailed Description

Jetty 12 implementation of WebSocketSession.

Wraps the native Jetty Session and exposes the framework's transport-agnostic WebSocket session contract. Each instance carries the request path, path parameters, query parameters, headers and a thread-safe attribute bag.

Definition at line 53 of file JettyWebSocketSession.java.

Constructor & Destructor Documentation

◆ JettyWebSocketSession()

dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.JettyWebSocketSession ( final Session session,
final String path,
final Map< String, String > pathParams,
final Map< String, List< String > > queryParams,
final Map< String, List< String > > headers )

Creates a session wrapper.

Parameters
sessionthe native Jetty WebSocket session
paththe matched request path
pathParamsextracted path parameters (e.g. "channel" -> "abc")
queryParamsquery string parameters
headersHTTP headers from the upgrade request
Exceptions
NullPointerExceptionif session or path is null

Definition at line 72 of file JettyWebSocketSession.java.

Member Function Documentation

◆ attribute() [1/2]

Object dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.attribute ( final String name)

Returns a session-scoped attribute by name.

Parameters
namethe attribute name
Returns
the attribute value, or null if not set

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 183 of file JettyWebSocketSession.java.

◆ attribute() [2/2]

void dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.attribute ( final String name,
final Object value )

Sets or removes a session-scoped attribute.

Passing null as the value removes the attribute.

Parameters
namethe attribute name
valuethe attribute value, or null to remove

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 196 of file JettyWebSocketSession.java.

◆ close()

CompletionStage< Void > dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.close ( final WebSocketCloseStatus status)

Closes the session with the given status code and reason.

Parameters
statusthe close status; defaults to WebSocketCloseStatus#NORMAL if null
Returns
a completion stage that completes when the close handshake finishes

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 267 of file JettyWebSocketSession.java.

◆ headerFirst()

String dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.headerFirst ( final String name)

Returns the first value of an HTTP header.

Parameters
namethe header name (case-sensitive)
Returns
the first value, or null if absent

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 168 of file JettyWebSocketSession.java.

◆ headers()

Map< String, List< String > > dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.headers ( )

Returns an unmodifiable view of all HTTP headers.

Returns
the header map

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 230 of file JettyWebSocketSession.java.

◆ id()

String dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.id ( )

Returns a unique session identifier derived from the native session's identity hash code.

Returns
a hex-encoded identity hash of the underlying session

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 88 of file JettyWebSocketSession.java.

◆ isOpen()

boolean dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.isOpen ( )

Returns whether the underlying session is still open.

Returns
true if the session is open

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 120 of file JettyWebSocketSession.java.

◆ path()

String dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.path ( )

Returns the matched request path.

Returns
the request path

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 98 of file JettyWebSocketSession.java.

◆ pathParam()

String dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.pathParam ( final String name)

Returns the value of a single path parameter by name.

Parameters
namethe path parameter name
Returns
the value, or null if the parameter does not exist

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 131 of file JettyWebSocketSession.java.

◆ pathParams()

Map< String, String > dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.pathParams ( )

Returns an unmodifiable view of all path parameters.

Returns
the path parameter map

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 210 of file JettyWebSocketSession.java.

◆ queryAll()

List< String > dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.queryAll ( final String name)

Returns all values of a query parameter.

Parameters
namethe query parameter name
Returns
an unmodifiable list of values (never null)

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 157 of file JettyWebSocketSession.java.

◆ queryFirst()

String dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.queryFirst ( final String name)

Returns the first value of a query parameter.

Parameters
namethe query parameter name
Returns
the first value, or null if absent

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 142 of file JettyWebSocketSession.java.

◆ queryParams()

Map< String, List< String > > dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.queryParams ( )

Returns an unmodifiable view of all query parameters.

Returns
the query parameter map

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 220 of file JettyWebSocketSession.java.

◆ sendBinary()

CompletionStage< Void > dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.sendBinary ( final ByteBuffer data)

Sends a binary message asynchronously.

Parameters
datathe binary payload (an empty buffer is sent if null)
Returns
a completion stage that completes when the message is sent

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 254 of file JettyWebSocketSession.java.

◆ sendText()

CompletionStage< Void > dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.sendText ( final String text)

Sends a text message asynchronously.

Parameters
textthe text payload
Returns
a completion stage that completes when the message is sent

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 241 of file JettyWebSocketSession.java.

◆ subprotocol()

String dev.rafex.ether.websocket.jetty12.JettyWebSocketSession.subprotocol ( )

Returns the accepted subprotocol, or an empty string if none was negotiated.

Returns
the negotiated subprotocol, or ""

Implements dev.rafex.ether.websocket.core.WebSocketSession.

Definition at line 108 of file JettyWebSocketSession.java.


The documentation for this class was generated from the following file: