Class AbstractWebSocketProcessor

  • All Implemented Interfaces:
    IWebSocketProcessor

    public abstract class AbstractWebSocketProcessor
    extends java.lang.Object
    implements IWebSocketProcessor
    The base implementation of IWebSocketProcessor. Provides the common logic for registering a web socket connection and broadcasting its events.
    Since:
    6.0
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractWebSocketProcessor​(javax.servlet.http.HttpServletRequest request, org.apache.wicket.protocol.http.WebApplication application)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void broadcastMessage​(IWebSocketMessage message)
      Exports the Wicket thread locals and broadcasts the received message from the client to all interested components and behaviors in the page with id #pageId
      protected org.apache.wicket.protocol.http.WebApplication getApplication()  
      protected IKey getRegistryKey()  
      protected java.lang.String getSessionId()  
      void onClose​(int closeCode, java.lang.String message)
      A notification after the close of the web socket connection.
      protected void onConnect​(IWebSocketConnection connection)
      A helper that registers the opened connection in the application-level registry.
      void onError​(java.lang.Throwable t)
      A notification after a communication error.
      void onMessage​(byte[] data, int offset, int length)
      Called when a binary message arrives from the client
      void onMessage​(java.lang.String message)
      Called when a text message arrives from the client
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractWebSocketProcessor

        public AbstractWebSocketProcessor​(javax.servlet.http.HttpServletRequest request,
                                          org.apache.wicket.protocol.http.WebApplication application)
        Constructor.
        Parameters:
        request - the http request that was used to create this IWebSocketProcessor
        application - the current Wicket Application
    • Method Detail

      • onMessage

        public void onMessage​(java.lang.String message)
        Description copied from interface: IWebSocketProcessor
        Called when a text message arrives from the client
        Specified by:
        onMessage in interface IWebSocketProcessor
        Parameters:
        message - the text message from the client
      • onMessage

        public void onMessage​(byte[] data,
                              int offset,
                              int length)
        Description copied from interface: IWebSocketProcessor
        Called when a binary message arrives from the client
        Specified by:
        onMessage in interface IWebSocketProcessor
        Parameters:
        data - the binary message from the client
        offset - the offset to read from
        length - how much data to read
      • onConnect

        protected final void onConnect​(IWebSocketConnection connection)
        A helper that registers the opened connection in the application-level registry.
        Parameters:
        connection - the web socket connection to use to communicate with the client
        See Also:
        IWebSocketProcessor.onOpen(Object)
      • onClose

        public void onClose​(int closeCode,
                            java.lang.String message)
        Description copied from interface: IWebSocketProcessor
        A notification after the close of the web socket connection. The connection could be closed by either the client or the server
        Specified by:
        onClose in interface IWebSocketProcessor
      • onError

        public void onError​(java.lang.Throwable t)
        Description copied from interface: IWebSocketProcessor
        A notification after a communication error.
        Specified by:
        onError in interface IWebSocketProcessor
        Parameters:
        t - The throwable for the communication problem
      • broadcastMessage

        public final void broadcastMessage​(IWebSocketMessage message)
        Exports the Wicket thread locals and broadcasts the received message from the client to all interested components and behaviors in the page with id #pageId

        Note: ConnectedMessage and ClosedMessage messages are notification-only. I.e. whatever the components/behaviors write in the WebSocketRequestHandler will be ignored because the protocol doesn't expect response from the user.

        Parameters:
        message - the message to broadcast
      • getApplication

        protected final org.apache.wicket.protocol.http.WebApplication getApplication()
      • getSessionId

        protected final java.lang.String getSessionId()
      • getRegistryKey

        protected IKey getRegistryKey()