Package io.mats3.matssocket
Interface MatsSocketServer.MatsSocketSession
- All Known Subinterfaces:
MatsSocketServer.ActiveMatsSocketSession
,MatsSocketServer.LiveMatsSocketSession
- All Known Implementing Classes:
MatsSocketServer.ActiveMatsSocketSessionDto
,MatsSocketServer.MatsSocketSessionDto
- Enclosing interface:
- MatsSocketServer
public static interface MatsSocketServer.MatsSocketSession
A MatsSocketSession, either as represented in the
data store
when gotten via
MatsSocketServer.getMatsSocketSessions(boolean, String, String, String)
(returning MatsSocketSessionDto
), or an ActiveMatsSocketSession
representing an active
MatsSocketSession connected to this node of the MatsSocketServer instance when gotten via
MatsSocketServer.getActiveMatsSocketSessions()
(returning ActiveMatsSocketSessionDto
),
or a LiveMatsSocketSession
which is an interface view over the actual live session
in the MatsSocketServer when gotten via MatsSocketServer.getLiveMatsSocketSessions()
.-
Method Summary
Modifier and TypeMethodDescriptionNote: Do realize that it is the Client that specifies this value, there is no restriction and you cannot trust that this String falls within your expected values.Note: Do realize that it is the Client that specifies this value, there is no restriction and you cannot trust that this String falls within your expected values.Note: Do realize that it is the Client that specifies this value, there is no restriction and you cannot trust that this String falls within your expected values.
-
Method Details
-
getMatsSocketSessionId
String getMatsSocketSessionId()- Returns:
- the MatsSocketSessionId of this MatsSocketSession.
-
getUserId
String getUserId()- Returns:
- the userId owning this MatsSocketSession.
-
getSessionCreatedTimestamp
Instant getSessionCreatedTimestamp()- Returns:
- when the MatsSocketSession and its Id was initially created. Will not be reset due to cycles of
MatsSocketServer.SessionRemovedEvent.SessionRemovedEventType.DEREGISTER
andMatsSocketServer.SessionEstablishedEvent.SessionEstablishedEventType.RECONNECT
, asMatsSocketServer.ActiveMatsSocketSession.getSessionEstablishedTimestamp()
does.
-
getSessionLivelinessTimestamp
Instant getSessionLivelinessTimestamp()- Returns:
- if this is an instance of
MatsSocketServer.ActiveMatsSocketSessionDto
, effectively returnsSystem.currentTimeMillis()
of whenMatsSocketServer.getActiveMatsSocketSessions()
was invoked, as it was live at the time of invocation). If this is an instance ofMatsSocketServer.LiveMatsSocketSession
, it literally returnsSystem.currentTimeMillis()
, as it is live right now. If this is an instance ofMatsSocketServer.MatsSocketSessionDto
, the reason you have this instance is that its contents was read from thedata store
usingMatsSocketServer.getMatsSocketSessions(boolean, String, String, String)
, and then this method returns last "liveliness update" from the data store, which is the last time this MatsSocketSession registered (i.e. became SESSION_ESTABLISHED), or from later periodic updates every few minutes while it is/was active.
-
getClientLibAndVersions
String getClientLibAndVersions()Note: Do realize that it is the Client that specifies this value, there is no restriction and you cannot trust that this String falls within your expected values.- Returns:
- a descriptive String representing which MatsSocket Client lib is in use ("name,version"), with
additional runtime "name and version" information tacked on separated by ";". For MatsSocket.js, this
may read as follows:
"MatsSocket.js,v0.10.0; User-Agent: {userAgentString}"
, or"MatsSocket.js,v0.10.0; Node.js: {node version}"
. For MatsSocket.dart, it could read"MatsSocket.dart,v0.10.0; Dart: {dart version}; Flutter: {flutter SDK version}"
, or"MatsSocket.dart,v0.10.0; Dart: {dart version}; User-Agent: {userAgentString}"
-
getAppName
String getAppName()Note: Do realize that it is the Client that specifies this value, there is no restriction and you cannot trust that this String falls within your expected values.- Returns:
- the "AppName" that the Client registers as, could be something like "MegaCorpWebBank". This should be rather long-term, not changing between versions of this particular application. It may be used to distinguish between two different apps using the same MatsSocketServer instance, where one of them handles Server-to-Client Requests of type "UserInfo.getCurrentGpsPosition", while the other app does not have this endpoint.
-
getAppVersion
String getAppVersion()Note: Do realize that it is the Client that specifies this value, there is no restriction and you cannot trust that this String falls within your expected values.- Returns:
- the "AppVersion" that the Client registers as, could be something like "1.2.3-2020-04-07_beta". This should be something sane, preferably which can be alphanum-compared, so that the server could know that at-or-above "1.2.1xxxx", the app "MegaCorpWebBank" handles Server-to-Client Requests of type "UserInfo.getCurrentGpsPosition", but before this version, that particular endpoint was not available.
-
getNodeName
- Returns:
- the name of the node that holds the
LiveMatsSocketSession
if it is active (i.e. state=SESSION_ESTABLISHED
),Optional.empty()
if not active. Will always return non-empty on anMatsSocketServer.ActiveMatsSocketSession
andMatsSocketServer.LiveMatsSocketSession
instance.
-