Interface WebSocketListener

All Superinterfaces:
org.springframework.web.socket.SubProtocolCapable
All Known Implementing Classes:
WebSocketInboundChannelAdapter

public interface WebSocketListener
extends org.springframework.web.socket.SubProtocolCapable
A contract for handling incoming WebSocketMessages messages as part of a higher level protocol, referred to as "sub-protocol" in the WebSocket RFC specification.

Implementations of this interface can be configured on a IntegrationWebSocketContainer which delegates messages and WebSocketSession events to this implementation.

Since:
4.1
See Also:
WebSocketInboundChannelAdapter
  • Method Summary

    Modifier and Type Method Description
    void afterSessionEnded​(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus closeStatus)
    Invoked after a WebSocketSession has ended.
    void afterSessionStarted​(org.springframework.web.socket.WebSocketSession session)
    Invoked after a WebSocketSession has started.
    void onMessage​(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.WebSocketMessage<?> message)
    Handle the received WebSocketMessage.

    Methods inherited from interface org.springframework.web.socket.SubProtocolCapable

    getSubProtocols
  • Method Details

    • onMessage

      void onMessage​(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.WebSocketMessage<?> message) throws java.lang.Exception
      Handle the received WebSocketMessage.
      Parameters:
      session - the WebSocket session
      message - the WebSocket message
      Throws:
      java.lang.Exception - the 'onMessage' Exception
    • afterSessionStarted

      void afterSessionStarted​(org.springframework.web.socket.WebSocketSession session) throws java.lang.Exception
      Invoked after a WebSocketSession has started.
      Parameters:
      session - the WebSocket session
      Throws:
      java.lang.Exception - the 'afterSessionStarted' Exception
    • afterSessionEnded

      void afterSessionEnded​(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus closeStatus) throws java.lang.Exception
      Invoked after a WebSocketSession has ended.
      Parameters:
      session - the WebSocket session
      closeStatus - the reason why the session was closed
      Throws:
      java.lang.Exception - the 'afterSessionEnded' Exception