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 -
Method Summary
Modifier and TypeMethodDescriptionvoidclose(jakarta.websocket.Session session) This gets called by the WebSocket implementation of the application server, once a session is closed.booleandispatch(com.levigo.jadice.web.transport.server.session.internal.ServerToClientMessage message) Try to dispatch a message via the transport connection to the connected client.voidThis gets called by the WebSocket implementation of the application server, once aThrowablewas thrown.com.levigo.jadice.web.transport.server.session.internal.ClientSessionRegistryDeprecated.Return the method used to communicate with the client, i.e. the kind of transport that is used.voidinit(com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal transportManager) Sets the currentTransportManager.voidmessage(jakarta.websocket.Session session, jakarta.websocket.PongMessage pongMsg) This is fired by the WebSocket implementation of the application server, once aPongMessagewas received.voidThis is fired by the WebSocket implementation of the application server, once a message was received.voidopen(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.voidshutdown()Perform a server-initiated shutdown of the transport session.
-
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 implementationclientId- the identifier of the client, passed with the client requestlastEventId- the id of the latest event, passed with the client requestconfig- the configuration of this e ndpoint given by the websocket container- Throws:
IOException- once an error occurred sending initial messages
-
message
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 servermessage- 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 aPongMessagewas 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 serverpongMsg- this is the pong message of the WebSocket protocol that was received from the client- See Also:
-
error
This gets called by the WebSocket implementation of the application server, once aThrowablewas thrown.- Parameters:
session- this is the WebSocket session for the client that gets injected by the application servert- 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 currentTransportManager.- Parameters:
transportManager- the currentTransportManager.
-
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.TransportSessionTry to dispatch a message via the transport connection to the connected client. Returntrueif dispatching was successful,falseotherwise.- Specified by:
dispatchin interfacecom.levigo.jadice.web.transport.server.session.internal.TransportSession- Parameters:
message- that should be sent to the client.- Returns:
trueif message could be forwarded,falseotherwise
-
getMethod
Description copied from interface:com.levigo.jadice.web.transport.server.session.internal.TransportSessionReturn the method used to communicate with the client, i.e. the kind of transport that is used.- Specified by:
getMethodin interfacecom.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.TransportSessionPerform a server-initiated shutdown of the transport session.- Specified by:
shutdownin interfacecom.levigo.jadice.web.transport.server.session.internal.TransportSession
-