Class SilverpeasWebSocketContext
- java.lang.Object
-
- org.silverpeas.core.notification.sse.SilverpeasWebSocketContext
-
- All Implemented Interfaces:
SilverpeasServerEventContext
public class SilverpeasWebSocketContext extends Object
This is a wrap of aSession
instance.All Server Event requests performed from a WebSocket MUST be wrapped by this implementation and registered by
SilverpeasServerEventContextManager
.- Author:
- silveryocha
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the context.boolean
equals(Object obj)
Long
getLastServerEventId()
Gets the last server event identifier known before a network breakdown.protected SilverpeasServerEventContextManager
getManager()
String
getRequestURI()
Gets the request URI behind the async context.String
getSessionId()
Gets the session identifier linked to the context.User
getUser()
Gets the user identifier linked to the context.protected W
getWrappedInstance()
int
hashCode()
boolean
isSendPossible()
Indicates if the sending is yet possible.void
performEventSend(String name, long id, String data)
boolean
sendEvent(String name, long id, String data)
Sends the given using elements of the context.void
setLastServerEventId(Long lastServerEventId)
Sets the last server event identifier.String
toString()
static SilverpeasWebSocketContext
wrap(javax.websocket.Session session, String userSessionId, User user)
Wraps the given instance.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.notification.sse.SilverpeasServerEventContext
closeOnPreviousCheckFailure, sendHeartbeatIfEnabled
-
-
-
-
Method Detail
-
wrap
public static SilverpeasWebSocketContext wrap(javax.websocket.Session session, String userSessionId, User user)
Wraps the given instance. Nothing is wrapped if the given instance is a wrapped one.- Parameters:
session
- the instance to wrap.userSessionId
- the identifier or the user session.user
- the identifier of th user linked to the async request.- Returns:
- the wrapped given instance.
-
getRequestURI
public String getRequestURI()
Gets the request URI behind the async context.- Returns:
- a request URI as string.
-
isSendPossible
public boolean isSendPossible()
Description copied from interface:SilverpeasServerEventContext
Indicates if the sending is yet possible.- Returns:
- true if possible, false otherwise.
-
close
public void close()
Description copied from interface:SilverpeasServerEventContext
Closes the context.It will be removed from the management context handled by
SilverpeasServerEventContextManager
.
-
performEventSend
public void performEventSend(String name, long id, String data) throws IOException
- Throws:
IOException
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object obj)
-
getSessionId
public String getSessionId()
Description copied from interface:SilverpeasServerEventContext
Gets the session identifier linked to the context.Be careful, according to the WEB context, the session identifier is not necessarily the JSESSIONID.
- Specified by:
getSessionId
in interfaceSilverpeasServerEventContext
- Returns:
- a session identifier as string.
-
getUser
public User getUser()
Description copied from interface:SilverpeasServerEventContext
Gets the user identifier linked to the context.- Specified by:
getUser
in interfaceSilverpeasServerEventContext
- Returns:
- a user identifier as string.
-
getLastServerEventId
public Long getLastServerEventId()
Description copied from interface:SilverpeasServerEventContext
Gets the last server event identifier known before a network breakdown.- Specified by:
getLastServerEventId
in interfaceSilverpeasServerEventContext
- Returns:
- an identifier as string.
-
setLastServerEventId
public void setLastServerEventId(Long lastServerEventId)
Sets the last server event identifier.- Specified by:
setLastServerEventId
in interfaceSilverpeasServerEventContext
- Parameters:
lastServerEventId
- a last event identifier as long, can be null.
-
getWrappedInstance
protected W getWrappedInstance()
-
getManager
protected SilverpeasServerEventContextManager getManager()
-
sendEvent
public boolean sendEvent(String name, long id, String data) throws IOException
Description copied from interface:SilverpeasServerEventContext
Sends the given using elements of the context.If sending has not been done, then context is removed from the context manager.
- Specified by:
sendEvent
in interfaceSilverpeasServerEventContext
- Parameters:
name
- the name of the event.id
- the unique identifier of the event (from the start of the server).data
- the data sent with the event.- Returns:
- true if send has been done, false otherwise.
- Throws:
IOException
-
-