Interface InternalSession
- All Superinterfaces:
AuditingContext
,LoggingContext
,PerspectiveElement
,PropertyTreeOwner
,Session
- All Known Implementing Classes:
AbstractSession
,PerspectiveDesignSession
,PerspectiveProjectSession
,SecuredPerspectiveProjectSession
,SessionKernelWrapper
The internal interface to sessions used by the system to coordinate the lifecycle and inner workings of the
session with the communications from clients and designers.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
A page visitor interface.Nested classes/interfaces inherited from interface com.inductiveautomation.perspective.gateway.api.Session
Session.WebAuthStatusChangeEvent
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionOptional<com.inductiveautomation.ignition.common.gson.JsonElement>
claimToken
(String type, String token) Claim the given token associated with the given data type previously created by this session.default void
Destroys this session and moves clients to a terminal state of closedvoid
Shuts down and removes the page associated with the given page ID which will disconnect the associated message channel (if one is connected).void
Shuts down and removes the page associated with the given page ID which will disconnect the associated message channel (if one is connected).createToken
(String type, com.inductiveautomation.ignition.common.gson.JsonElement data) Create a new token associated with the given type and data for the this session.default void
Destroys the session by removing it from its containing session collection and shutting it down (which should close any connected message channels).Find thePage
associated with the given page IDint
int
long
getLastComm
(TimeUnit timeUnit) Return the time in the given time unit when the last communication was received from the clientThe current locale for this session, or a safe defaultLocale.getDefault()
if not available.getOrCreatePage
(String pageId) Fetch thePageModel
associated with the given page ID.int
getPages()
default PerspectiveContext
default PerspectiveProject
Fetch the project associated with this session.default TimeZone
The current timezone for this session, or a safe default if not available.The current timezone id for this session, or a safe default if not available.long
Return the amount of time elapsed in the given time unit since the session started up.int
boolean
Logout of this session.void
notifyConnected
(MessageChannel channel) Let the session know that the page has connectedvoid
notifyDisconnected
(MessageChannel channel) Let the session know that the page has disconnectedvoid
onHello()
Called every time the hello API is invoked on this session.void
onKeepaliveReceived
(String pageId, long timestamp) Called by the client to keep the session alive.void
onLoginResponse
(WebAuthResponseContext webAuthResponseContext) Called when the session receives a login response from the IdPvoid
onLogoutResponse
(WebAuthResponseContext webAuthResponseContext) Called when this session received a logout response from the IdPvoid
onSessionInit
(com.inductiveautomation.ignition.common.gson.JsonObject sessionInitResponse) Called during the session-init lifecycle of the client.void
receive
(MessageChannel channel, String protocol, Reader payload) Called when this session has received a message from the message channel.default SessionScope
scope()
The scope in which this context represents -- Client or Designervoid
shutdown()
Shut down the session.void
startup()
Start up the session.void
updateSessionProps
(SessionPropsConfig config) Update the props and bindings associated with this sessionvoid
visitPage
(String pageId, InternalSession.PageVisitor visitor) Visit the page associated with the given ID.Methods inherited from interface com.inductiveautomation.perspective.gateway.api.AuditingContext
audit, getAuditSnapshot
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.LoggingContext
getLogger, mdc, mdcSetupTree, mdcTeardownTree, mdcWrap
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.PerspectiveElement
createPropertyReference, getAuditProfile, getQualifiedPath
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.PropertyTreeOwner
getPropertyTreeOf
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.Session
createViewModel, findViewConfig, getEventBus, getEventManager, getGatewayContext, getMdcParent, getName, getNamedQueryManager, getPage, getPageTimeout, getProjectName, getScriptManager, getSession, getSessionId, getSessionStats, getTagHistoryManager, getTagManager, getView, getWebAuthStatus, mdcSetup, mdcTeardown, queue, refreshBinding, sendErrorToDesigner
-
Field Details
-
SESSION
-
-
Method Details
-
startup
void startup()Start up the session.- Throws:
IllegalStateException
- if the session has already been started or shutdown
-
shutdown
void shutdown()Shut down the session.- Throws:
IllegalStateException
- if the session has not been started or if it has already been shut down
-
isRunning
boolean isRunning()- Specified by:
isRunning
in interfacePerspectiveElement
- Returns:
- true if the session has started and has not yet been shut down
- See Also:
-
notifyConnected
Let the session know that the page has connected- Parameters:
channel
- theMessageChannel
used for communications between the client page and the gateway page
-
notifyDisconnected
Let the session know that the page has disconnected- Parameters:
channel
- theMessageChannel
used for communications between the client page and the gateway page
-
destroySession
default void destroySession()Destroys the session by removing it from its containing session collection and shutting it down (which should close any connected message channels). -
receive
Called when this session has received a message from the message channel.- Parameters:
channel
- theMessageChannel
from which the message was receivedprotocol
- the protocol of the messagepayload
- the payload of the message
-
getOrCreatePage
Fetch thePageModel
associated with the given page ID. If the page does not exist, it is created, associated with the given page ID, and returned.- Parameters:
pageId
- the page ID associated with the target page- Returns:
- the page associated with the given page ID or a new page if it does not exist
-
findPage
Description copied from interface:Session
Find thePage
associated with the given page ID -
getPages
-
getPageCount
int getPageCount() -
getViewCount
int getViewCount() -
getComponentCount
int getComponentCount() -
getBindingCount
int getBindingCount() -
visitPage
Visit the page associated with the given ID. If the page is found,InternalSession.PageVisitor.onPageFound(PageModel)
is invoked with the target page. If the page is not found,InternalSession.PageVisitor.onPageMissing()
is invoked. If the page is closed,InternalSession.PageVisitor.onPageClosed(String)
is invoked with the closed message.- Parameters:
pageId
- the target page IDvisitor
- the page visitor
-
closePage
Shuts down and removes the page associated with the given page ID which will disconnect the associated message channel (if one is connected).- Parameters:
pageId
- the page ID associated with the target page
-
closePage
Shuts down and removes the page associated with the given page ID which will disconnect the associated message channel (if one is connected). Moves the client to a terminal state page of closed with the given message.- Parameters:
pageId
- the page ID associated with the target pagemessage
- the message displayed to the client on the terminal state page
-
onSessionInit
void onSessionInit(com.inductiveautomation.ignition.common.gson.JsonObject sessionInitResponse) Called during the session-init lifecycle of the client. Implementations may modify the given response JSON object to pass back to the client.- Parameters:
sessionInitResponse
- the response JSON object to be passed back to the client in response to the session-init call
-
logout
Logout of this session. The user will no longer be authenticated.- Parameters:
message
- the message to display to the user after they are logged out of this session- Returns:
- a logout token or hint for the IdP if one is available
-
onLoginResponse
Called when the session receives a login response from the IdP- Parameters:
webAuthResponseContext
- the login response object
-
onLogoutResponse
Called when this session received a logout response from the IdP- Parameters:
webAuthResponseContext
- the logout response object
-
getSessionCollection
PerspectiveSessionCollection getSessionCollection()- Returns:
- the
PerspectiveSessionCollection
which contains this session
-
getPerspectiveContext
- Specified by:
getPerspectiveContext
in interfaceSession
-
scope
Description copied from interface:Session
The scope in which this context represents -- Client or Designer -
getLocale
Locale getLocale()The current locale for this session, or a safe defaultLocale.getDefault()
if not available. -
getTimeZoneId
String getTimeZoneId()The current timezone id for this session, or a safe default if not available. -
getTimeZone
The current timezone for this session, or a safe default if not available. -
onKeepaliveReceived
Called by the client to keep the session alive.- Parameters:
pageId
- the page ID of the page which triggered the keep alive requesttimestamp
- the timestamp associated with the keep alive request
-
updateSessionProps
Update the props and bindings associated with this session- Parameters:
config
- the session props config to apply
-
getProject
Fetch the project associated with this session.- Returns:
- the
PerspectiveProject
associated with this session - Throws:
IllegalStateException
- if the project associated with this session does not exist
-
onHello
void onHello()Called every time the hello API is invoked on this session. -
getSessionInfo
PerspectiveSessionInfo getSessionInfo()- Returns:
- a report about this session
-
getUptime
Return the amount of time elapsed in the given time unit since the session started up.- Parameters:
timeUnit
- theTimeUnit
to which the internal startup time should be converted- Returns:
- the up time in the given unit
-
getLastComm
Return the time in the given time unit when the last communication was received from the client- Parameters:
timeUnit
- theTimeUnit
to which the last communication time should be converted- Returns:
- the last communication time in the given unit
-
getSessionClosedMessage
String getSessionClosedMessage()- Returns:
- the default message sent to the client when the session is closed
-
getPageClosedMessage
String getPageClosedMessage()- Returns:
- the default message sent to the client then a page is closed
-
getLogoutMessage
String getLogoutMessage()- Returns:
- the default message sent to the client when the user logs out
-
close
Description copied from interface:Session
Destroys this session and moves clients to a terminal state of closed -
createToken
Create a new token associated with the given type and data for the this session. The token expires in 30 seconds.- Returns:
- the new short-lived token
-
claimToken
Optional<com.inductiveautomation.ignition.common.gson.JsonElement> claimToken(String type, String token) Claim the given token associated with the given data type previously created by this session.- Parameters:
token
- the token to claim- Returns:
- an
Optional
containing theJsonElement
data associated with the given data type and token, or an empty Optional if no data exists for the given data type and token pair
-