Class AbstractXWikiEndpoint

  • All Implemented Interfaces:
    org.xwiki.websocket.EndpointComponent

    public abstract class AbstractXWikiEndpoint
    extends javax.websocket.Endpoint
    implements org.xwiki.websocket.EndpointComponent
    Base class for WebSocket end-points that require the XWiki execution context to be properly set-up.
    Since:
    13.7RC1
    Version:
    $Id: af8cee9fc621f555ab899abd0c8738b0c4e54041 $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.xwiki.websocket.WebSocketContext context  
      protected org.slf4j.Logger logger  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void close​(javax.websocket.Session session, javax.websocket.CloseReason.CloseCode closeCode, String reasonPhrase)
      Try to close the given session using the specified code and reason.
      protected <T> void handleMessage​(javax.websocket.Session session, T message)
      Handles a received message by calling either onMessage(Session, T) or onMessage(T).
      protected <T> void handleMessage​(javax.websocket.Session session, T message, boolean last)
      Handles a received message by calling either onMessage(Session, T) or onMessage(T).
      • Methods inherited from class javax.websocket.Endpoint

        onClose, onError, onOpen
    • Field Detail

      • logger

        @Inject
        protected org.slf4j.Logger logger
      • context

        @Inject
        protected org.xwiki.websocket.WebSocketContext context
    • Constructor Detail

      • AbstractXWikiEndpoint

        public AbstractXWikiEndpoint()
    • Method Detail

      • handleMessage

        protected <T> void handleMessage​(javax.websocket.Session session,
                                         T message)
        Handles a received message by calling either onMessage(Session, T) or onMessage(T). If the value returned by onMessage matches the message type then we send it back.
        Type Parameters:
        T - the message type
        Parameters:
        session - the WebSocket session in which the message was received
        message - the received message
      • handleMessage

        protected <T> void handleMessage​(javax.websocket.Session session,
                                         T message,
                                         boolean last)
        Handles a received message by calling either onMessage(Session, T) or onMessage(T). If the value returned by onMessage matches the message type then we send it back.
        Type Parameters:
        T - the message type
        Parameters:
        session - the WebSocket session in which the message was received
        message - the received message
        last - whether this is the last message chunk or not, useful when handling partial messages
      • close

        protected void close​(javax.websocket.Session session,
                             javax.websocket.CloseReason.CloseCode closeCode,
                             String reasonPhrase)
        Try to close the given session using the specified code and reason.
        Parameters:
        session - the session to close
        closeCode - the error code
        reasonPhrase - the reason to close the session