Class WebSocketTransportEndpoint

java.lang.Object
com.levigo.jadice.web.transport.server.networking.websocket.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.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    close(jakarta.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(jakarta.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
    Deprecated.
    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(jakarta.websocket.Session session, jakarta.websocket.PongMessage pongMsg)
    This is fired by the WebSocket implementation of the application server, once a PongMessage was received.
    void
    message(jakarta.websocket.Session session, String message, boolean last)
    This is fired by the WebSocket implementation of the application server, once a message was received.
    void
    open(jakarta.websocket.Session session, String clientId, Long lastEventId, jakarta.websocket.EndpointConfig config)
    This gets called by the WebSocket implementation of the application server, once a session is opened.
    void
    Perform a server-initiated shutdown of the transport session.

    Methods inherited from class java.lang.Object

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

    • WebSocketTransportEndpoint

      public WebSocketTransportEndpoint()
  • Method Details

    • open

      public void open(jakarta.websocket.Session session, String clientId, Long lastEventId, jakarta.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(jakarta.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(jakarta.websocket.Session session, jakarta.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:
    • error

      public void error(jakarta.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(jakarta.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