Class SilverpeasServerEventWebSocket
- java.lang.Object
-
- org.silverpeas.core.webapi.notification.sse.SilverpeasServerEventWebSocket
-
- Direct Known Subclasses:
CommonServerEventWebSocket
public abstract class SilverpeasServerEventWebSocket extends Object
This abstraction defines the behavior the Servlets in charge of responding to EventSource JavaScript API must have.
Finally, adding a new URI to handle EventSource needs to extends this class and to parametrize the mapping! (seeCommonServerSentEventServlet
as an example)- Author:
- Yohann Chastagnier
-
-
Constructor Summary
Constructors Constructor Description SilverpeasServerEventWebSocket()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Default Methods Modifier and Type Method Description protected SessionInfo
getSessionInfo(javax.websocket.Session wsSession)
This method is called one time only, whenonOpen(Session)
is executed.protected abstract String
getTokenParameterName()
Gets the name of the parameter representing the token generated for current authenticated user and passed in the URI of the WebSocket endpoint.void
onClose(javax.websocket.Session wsSession)
void
onError(javax.websocket.Session wsSession, Throwable throwable)
void
onMessage(javax.websocket.Session wsSession, String message)
void
onOpen(javax.websocket.Session wsSession)
default void
prepareEventsOnOpening(org.silverpeas.core.webapi.notification.sse.SilverpeasServerEventWebAccess.WebAccessContext wac, Long initialLastServerEventId)
default void
send(org.silverpeas.core.webapi.notification.sse.SilverpeasServerEventWebAccess.WebAccessContext wac, SilverpeasServerEventContext context)
-
-
-
Method Detail
-
getTokenParameterName
protected abstract String getTokenParameterName()
Gets the name of the parameter representing the token generated for current authenticated user and passed in the URI of the WebSocket endpoint.For example: With the
@ServerEndpoint("/ws/{token}/sse/common")
declaration, "token" MUST be returned by this method.- Returns:
- a string representing the parameter name for the token.
-
getSessionInfo
protected SessionInfo getSessionInfo(javax.websocket.Session wsSession)
This method is called one time only, whenonOpen(Session)
is executed.- Parameters:
wsSession
- a WebSocket session instance.- Returns:
- a
SessionInfo
instance.
-
onOpen
public void onOpen(javax.websocket.Session wsSession) throws IOException
- Throws:
IOException
-
onClose
public void onClose(javax.websocket.Session wsSession)
-
onError
public void onError(javax.websocket.Session wsSession, Throwable throwable)
-
onMessage
public void onMessage(javax.websocket.Session wsSession, String message)
-
prepareEventsOnOpening
public default void prepareEventsOnOpening(org.silverpeas.core.webapi.notification.sse.SilverpeasServerEventWebAccess.WebAccessContext wac, Long initialLastServerEventId)
-
send
public default void send(org.silverpeas.core.webapi.notification.sse.SilverpeasServerEventWebAccess.WebAccessContext wac, SilverpeasServerEventContext context) throws IOException
- Throws:
IOException
-
-