org.springframework.web.reactive.socket.adapter

## Class AbstractWebSocketSession<T>

- java.lang.Object
- - org.springframework.web.reactive.socket.adapter.AbstractWebSocketSession<T>

Type Parameters:
  `T` - the native delegate type

All Implemented Interfaces:
  WebSocketSession

Direct Known Subclasses:
  AbstractListenerWebSocketSession, NettyWebSocketSessionSupport

    public abstract class AbstractWebSocketSession<T>
    extends Object
    implements WebSocketSession

Convenient base class for `WebSocketSession` implementations that holds common fields and exposes accessors. Also implements the `WebSocketMessage` factory methods.

Since:
  5.0
Author:
  Rossen Stoyanchev

### Field Summary

Fields
`protected Log` `logger`

### Constructor Summary

Constructors
`protected` `AbstractWebSocketSession(T delegate, String id, HandshakeInfo info, org.springframework.core.io.buffer.DataBufferFactory bufferFactory)` Create a new WebSocket session.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`WebSocketMessage` `binaryMessage(Function<org.springframework.core.io.buffer.DataBufferFactory,org.springframework.core.io.buffer.DataBuffer> payloadFactory)` Factory method to create a binary WebSocketMessage using the `WebSocketSession.bufferFactory()` for the session.
`org.springframework.core.io.buffer.DataBufferFactory` `bufferFactory()` Return a `DataBuffer` Factory to create message payloads.
`Map<String,Object>` `getAttributes()` Return the map with attributes associated with the WebSocket session.
`protected T` `getDelegate()`
`HandshakeInfo` `getHandshakeInfo()` Return information from the handshake request.
`String` `getId()` Return the id for the session.
`protected String` `getLogPrefix()`
`WebSocketMessage` `pingMessage(Function<org.springframework.core.io.buffer.DataBufferFactory,org.springframework.core.io.buffer.DataBuffer> payloadFactory)` Factory method to create a ping WebSocketMessage using the `WebSocketSession.bufferFactory()` for the session.
`WebSocketMessage` `pongMessage(Function<org.springframework.core.io.buffer.DataBufferFactory,org.springframework.core.io.buffer.DataBuffer> payloadFactory)` Factory method to create a pong WebSocketMessage using the `WebSocketSession.bufferFactory()` for the session.
`abstract reactor.core.publisher.Flux<WebSocketMessage>` `receive()` Provides access to the stream of inbound messages.
`abstract reactor.core.publisher.Mono<Void>` `send(org.reactivestreams.Publisher<WebSocketMessage> messages)` Give a source of outgoing messages, write the messages and return a `Mono<Void>` that completes when the source completes and writing is done.
`WebSocketMessage` `textMessage(String payload)` Factory method to create a text `WebSocketMessage` using the `WebSocketSession.bufferFactory()` for the session.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.web.reactive.socket.WebSocketSession

`close, close`

### Field Detail

#### logger

    protected final Log logger

### Constructor Detail

#### AbstractWebSocketSession

    protected AbstractWebSocketSession(T delegate,
                                       String id,
                                       HandshakeInfo info,
                                       org.springframework.core.io.buffer.DataBufferFactory bufferFactory)

Create a new WebSocket session.

### Method Detail

#### getDelegate

    protected T getDelegate()

#### getId

    public String getId()

Description copied from interface: `WebSocketSession`
Return the id for the session.

Specified by:
  `getId` in interface `WebSocketSession`

#### getHandshakeInfo

    public HandshakeInfo getHandshakeInfo()

Description copied from interface: `WebSocketSession`
Return information from the handshake request.

Specified by:
  `getHandshakeInfo` in interface `WebSocketSession`

#### bufferFactory

    public org.springframework.core.io.buffer.DataBufferFactory bufferFactory()

Description copied from interface: `WebSocketSession`
Return a `DataBuffer` Factory to create message payloads.

Specified by:
  `bufferFactory` in interface `WebSocketSession`
Returns:
  the buffer factory for the session

#### getAttributes

    public Map<String,Object> getAttributes()

Description copied from interface: `WebSocketSession`
Return the map with attributes associated with the WebSocket session.

Specified by:
  `getAttributes` in interface `WebSocketSession`
Returns:
  a Map with the session attributes (never `null`)

#### getLogPrefix

    protected String getLogPrefix()

#### receive

    public abstract reactor.core.publisher.Flux<WebSocketMessage> receive()

Description copied from interface: `WebSocketSession`
Provides access to the stream of inbound messages.

This stream receives a completion or error signal when the connection is closed. In a typical `WebSocketHandler` implementation this stream is composed into the overall processing flow, so that when the connection is closed, handling will end.

See the class-level doc of `WebSocketHandler` and the reference for more details and examples of how to handle the session.

Specified by:
  `receive` in interface `WebSocketSession`

#### send

    public abstract reactor.core.publisher.Mono<Void> send(org.reactivestreams.Publisher<WebSocketMessage> messages)

Description copied from interface: `WebSocketSession`
Give a source of outgoing messages, write the messages and return a `Mono<Void>` that completes when the source completes and writing is done.

See the class-level doc of `WebSocketHandler` and the reference for more details and examples of how to handle the session.

Specified by:
  `send` in interface `WebSocketSession`

#### textMessage

    public WebSocketMessage textMessage(String payload)

Description copied from interface: `WebSocketSession`
Factory method to create a text `WebSocketMessage` using the `WebSocketSession.bufferFactory()` for the session.

Specified by:
  `textMessage` in interface `WebSocketSession`

#### binaryMessage

    public WebSocketMessage binaryMessage(Function<org.springframework.core.io.buffer.DataBufferFactory,org.springframework.core.io.buffer.DataBuffer> payloadFactory)

Description copied from interface: `WebSocketSession`
Factory method to create a binary WebSocketMessage using the `WebSocketSession.bufferFactory()` for the session.

Specified by:
  `binaryMessage` in interface `WebSocketSession`

#### pingMessage

    public WebSocketMessage pingMessage(Function<org.springframework.core.io.buffer.DataBufferFactory,org.springframework.core.io.buffer.DataBuffer> payloadFactory)

Description copied from interface: `WebSocketSession`
Factory method to create a ping WebSocketMessage using the `WebSocketSession.bufferFactory()` for the session.

Specified by:
  `pingMessage` in interface `WebSocketSession`

#### pongMessage

    public WebSocketMessage pongMessage(Function<org.springframework.core.io.buffer.DataBufferFactory,org.springframework.core.io.buffer.DataBuffer> payloadFactory)

Description copied from interface: `WebSocketSession`
Factory method to create a pong WebSocketMessage using the `WebSocketSession.bufferFactory()` for the session.

Specified by:
  `pongMessage` in interface `WebSocketSession`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`