Class WebSocketTransportEndpoint

  • All Implemented Interfaces:
    com.levigo.jadice.web.transport.server.session.internal.TransportSession

    public class WebSocketTransportEndpoint
    extends Object
    implements com.levigo.jadice.web.transport.server.session.internal.TransportSession
    The WebSocketTransportEndpoint dispatches all incoming and/or outgoing messages using the WebSocket protocol.

    Note: The WebSocket container will instantiate a new instance of this class for each client.

    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void close​(javax.websocket.Session session)
      This gets called by the WebSocket implementation of the application server, once a session is closed.
      boolean dispatch​(com.levigo.jadice.web.transport.server.session.internal.ServerToClientMessage message)
      Try to dispatch a message via the transport connection to the connected client.
      void error​(javax.websocket.Session session, Throwable t)
      This gets called by the WebSocket implementation of the application server, once a Throwable was thrown.
      com.levigo.jadice.web.transport.server.session.internal.ClientSessionRegistry getClientSessionRegistry()
      Deprecated.
      Method getMethod()
      Return the method used to communicate with the client, i.e.
      void init​(com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal transportManager)
      Sets the current TransportManager.
      void message​(javax.websocket.Session session, String message, boolean last)
      This is fired by the WebSocket implementation of the application server, once a message was received.
      void message​(javax.websocket.Session session, javax.websocket.PongMessage pongMsg)
      This is fired by the WebSocket implementation of the application server, once a PongMessage was received.
      void open​(javax.websocket.Session session, String clientId, Long lastEventId, javax.websocket.EndpointConfig config)
      This gets called by the WebSocket implementation of the application server, once a session is opened.
      void shutdown()
      Perform a server-initiated shutdown of the transport session.
    • Constructor Detail

      • WebSocketTransportEndpoint

        public WebSocketTransportEndpoint()
    • Method Detail

      • open

        public void open​(javax.websocket.Session session,
                         String clientId,
                         Long lastEventId,
                         javax.websocket.EndpointConfig config)
                  throws IOException
        This gets called by the WebSocket implementation of the application server, once a session is opened.
        Parameters:
        session - the session which was closed by the WebSocket implementation
        clientId - the identifier of the client, passed with the client request
        lastEventId - the id of the latest event, passed with the client request
        config - the configuration of this endpoint given by the websocket container
        Throws:
        IOException - once an error occurred sending initial messages
      • message

        public void message​(javax.websocket.Session session,
                            String message,
                            boolean last)
        This is fired by the WebSocket implementation of the application server, once a message was received.
        Parameters:
        session - this is the WebSocket session for the client that gets injected by the application server
        message - the message that was received from the client
      • message

        public void message​(javax.websocket.Session session,
                            javax.websocket.PongMessage pongMsg)
        This is fired by the WebSocket implementation of the application server, once a PongMessage was received.

        A pong is send as an answer of a ping. A Ping frame may serve either as a keepalive or as a means to verify that the remote endpoint is still responsive.

        Parameters:
        session - this is the WebSocket session for the client that gets injected by the application server
        pongMsg - this is the pong message of the WebSocket protocol that was received from the client
        See Also:
        The WebSocket Protocol
      • error

        public void error​(javax.websocket.Session session,
                          Throwable t)
        This gets called by the WebSocket implementation of the application server, once a Throwable was thrown.
        Parameters:
        session - this is the WebSocket session for the client that gets injected by the application server
        t - the error which was thrown by the WebSocket implementation
      • close

        public void close​(javax.websocket.Session session)
        This gets called by the WebSocket implementation of the application server, once a session is closed.
        Parameters:
        session - the session which was closed by the WebSocket implementation
      • getClientSessionRegistry

        @Deprecated
        public com.levigo.jadice.web.transport.server.session.internal.ClientSessionRegistry getClientSessionRegistry()
        Deprecated.
        Returns:
        the ClientSessionRegistry
      • init

        public void init​(com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal transportManager)
        Sets the current TransportManager.
        Parameters:
        transportManager - the current TransportManager.
      • dispatch

        public boolean dispatch​(com.levigo.jadice.web.transport.server.session.internal.ServerToClientMessage message)
        Description copied from interface: com.levigo.jadice.web.transport.server.session.internal.TransportSession
        Try to dispatch a message via the transport connection to the connected client. Return true if dispatching was successful, false otherwise.
        Specified by:
        dispatch in interface com.levigo.jadice.web.transport.server.session.internal.TransportSession
        Parameters:
        message - that should be sent to the client.
        Returns:
        true if message could be forwarded, false otherwise
      • getMethod

        public Method getMethod()
        Description copied from interface: com.levigo.jadice.web.transport.server.session.internal.TransportSession
        Return the method used to communicate with the client, i.e. the kind of transport that is used.
        Specified by:
        getMethod in interface com.levigo.jadice.web.transport.server.session.internal.TransportSession
        Returns:
        The current communication method of client.
      • shutdown

        public void shutdown()
        Description copied from interface: com.levigo.jadice.web.transport.server.session.internal.TransportSession
        Perform a server-initiated shutdown of the transport session.
        Specified by:
        shutdown in interface com.levigo.jadice.web.transport.server.session.internal.TransportSession