Package io.mats3.matssocket
Interface MatsSocketServer.LiveMatsSocketSession
- All Superinterfaces:
MatsSocketServer.ActiveMatsSocketSession
,MatsSocketServer.MatsSocketSession
- Enclosing interface:
- MatsSocketServer
public static interface MatsSocketServer.LiveMatsSocketSession
extends MatsSocketServer.ActiveMatsSocketSession
A live representation of a MatsSocketSession.
Note: The difference between "active" and "live" is that the "active" are dumb "data transfer objects" (DTOs)
which will serialize nicely with both Mats and MatsSocket field-based serialization mechanisms, while the "live"
are an interface to the actual live sessions in the MatsSocketServer, and as such has more information - but
cannot be (easily) serialized, and not passed as in- or out objects on Mats endpoints.
NOTE: The underlying instance is live in that it is just an interface over the live representation which the
MatsSocketServer is using to hold the MatsSocketSession. As such, most methods can return different values
between each time you invoke them - and there is no synchronization between the methods, so you could read ACTIVE
using
getState()
, but when you read MatsSocketServer.ActiveMatsSocketSession.getAuthorization()
, it could return Optional.empty() -
because the user concurrently closed the session (and if reading getState() again, it would now return CLOSED).-
Nested Class Summary
Nested classes/interfaces inherited from interface io.mats3.matssocket.MatsSocketServer.ActiveMatsSocketSession
MatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState
-
Method Summary
Methods inherited from interface io.mats3.matssocket.MatsSocketServer.ActiveMatsSocketSession
getAuthorization, getLastActivityTimestamp, getLastAuthenticatedTimestamp, getLastClientPingTimestamp, getLastEnvelopes, getOriginatingRemoteAddr, getPrincipalName, getRemoteAddr, getSessionEstablishedTimestamp, getTopicSubscriptions
Methods inherited from interface io.mats3.matssocket.MatsSocketServer.MatsSocketSession
getAppName, getAppVersion, getClientLibAndVersions, getMatsSocketSessionId, getNodeName, getSessionCreatedTimestamp, getSessionLivelinessTimestamp, getUserId
-
Method Details
-
getState
- Returns:
- the current state of this
ActiveMatsSocketSession
. You should really only ever seeSESSION_ESTABLISHED
, but due to the concurrency wrt. you getting hold of an LiveMatsSocketSession instance, and the Client performing aDEREGISTER
orCLOSE
, you may also observeDEREGISTERED
andCLOSED
.
-
getWebSocketSession
javax.websocket.Session getWebSocketSession()- Returns:
- the WebSocket Session - the JSR 356 Java WebSocket API representation of the actual WebSocket connection. You should not really mess too much with this..!
-
getPrincipal
- Returns:
- the active Principal, only available when
MatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState.SESSION_ESTABLISHED
.
-
getAllowedDebugOptions
EnumSet<AuthenticationPlugin.DebugOption> getAllowedDebugOptions()- Returns:
- the set of
AuthenticationPlugin.DebugOption
the the activeAuthenticationPlugin
allows thecurrent Principal
to request.
-
toActiveMatsSocketSession
MatsSocketServer.ActiveMatsSocketSessionDto toActiveMatsSocketSession()- Returns:
- a "frozen in time" copy of this LiveMatsSocketSession as an
MatsSocketServer.ActiveMatsSocketSessionDto
. Do observe that due to the concurrency of these live sessions, you may get a copy of when the session had become (state
)DEREGISTERED
orCLOSED
, and where some of the Optional-returning methods then returns Optional.empty(). If you do not want to handle such instances, then you might want to checkgetState()
after invoking this method, and if notSESSION_ESTABLISHED
, then ditch the instance that you just copied out - this is whatMatsSocketServer.getActiveMatsSocketSessions()
does.
-