Class AbstractSession<T extends SessionKernel>
java.lang.Object
com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
com.inductiveautomation.perspective.gateway.session.SessionKernelWrapper<T>
com.inductiveautomation.perspective.gateway.session.AbstractSession<T>
- All Implemented Interfaces:
AuditingContext
,LoggingContext
,PerspectiveElement
,PropertyTreeOwner
,Session
,InternalSession
,SessionKernel
- Direct Known Subclasses:
PerspectiveDesignSession
,PerspectiveProjectSession
Base class for perspective applications, whether that is a project running as a client, or a project being designed
in the designer. Provides the context for Page objects to function in.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.inductiveautomation.perspective.gateway.session.InternalSession
InternalSession.PageVisitor
Nested classes/interfaces inherited from interface com.inductiveautomation.perspective.gateway.api.Session
Session.WebAuthStatusChangeEvent
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BindingCollection
protected PropertyChangeScriptCollection
protected final MessageProtocolDispatcher
Collection of active pages.protected Map<PropertyType,
PropertyTree> Holds session.props and session.custom property trees.Fields inherited from interface com.inductiveautomation.perspective.gateway.session.InternalSession
SESSION
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Broadcast a message to all pages associated with this sessionvoid
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).protected PropertyTreePermissionModel
createPermissionModel
(PropertyType scope, PropertyConfigCollection config) Find thePage
associated with the given page IDprotected Optional<SessionPropsConfig>
int
int
long
The current locale for this session, or a safe defaultLocale.getDefault()
if not available.getOrCreatePage
(String pageId) Returns a page for the given key, where the key itself is relevant to the session scope.int
com.inductiveautomation.ignition.common.gson.JsonArray
Collects the "brief report " json structure of each running page in this session.getPages()
getPropertyTreeOf
(PropertyType propertyType) Fetch thePropertyTree
associated with the givenPropertyType
The current timezone id for this session, or a safe default if not available.int
protected Map<PropertyType,
PropertyTree> initProperties
(SessionPropsConfig config) protected abstract void
Call this when it's possible the last page has been closed.protected PageModel
void
notifyConnected
(MessageChannel channel) Should notifyPageModel
s which are associated with this channel that the websocket has connected.void
notifyDisconnected
(MessageChannel channel) Called when a message channel has disconnected.void
onKeepaliveReceived
(String pageId, long timestamp) Called by the client to keep the session alive.void
onSessionInit
(com.inductiveautomation.ignition.common.gson.JsonObject sessionInitResponse) Called when handling the session-init message.void
receive
(MessageChannel channel, String protocol, Reader payload) Called when this session has received a message from the message channel.void
refreshBinding
(PropertyKey property) Refresh the binding for the given propertyprotected void
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 class com.inductiveautomation.perspective.gateway.session.SessionKernelWrapper
claimToken, createToken, getAuditSnapshot, getEventBus, getEventManager, getGson, getLastComm, getLastMessageTime, getLogger, getLogoutMessage, getPageClosedMessage, getProjectName, getSessionClosedMessage, getSessionCollection, getSessionId, getSessionInfo, getSessionStats, getStartupTime, getUptime, onHello, onShutdown, onStartup, queue, touch
Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
isRunning, shutdown, startup
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.AuditingContext
audit
Methods inherited from interface com.inductiveautomation.perspective.gateway.session.InternalSession
close, destroySession, getPerspectiveContext, getProject, getTimeZone, isRunning, logout, onLoginResponse, onLogoutResponse, scope, shutdown, startup
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.LoggingContext
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.Session
createViewModel, findViewConfig, getGatewayContext, getMdcParent, getName, getNamedQueryManager, getPage, getPageTimeout, getScriptManager, getSession, getTagHistoryManager, getTagManager, getView, getWebAuthStatus, mdcSetup, mdcTeardown, sendErrorToDesigner
Methods inherited from interface com.inductiveautomation.perspective.gateway.session.SessionKernel
shutdown, startup
-
Field Details
-
handlers
-
pages
Collection of active pages. Key of this map is the "page id" (a string). In the non-designer session, a perspective application may be running across multiple browser tabs. Each tab is its own "page" and has its own page id -
props
Holds session.props and session.custom property trees. -
bindings
-
changeScripts
-
-
Method Details
-
getPropertyTreeOf
Description copied from interface:PropertyTreeOwner
Fetch thePropertyTree
associated with the givenPropertyType
- Parameters:
propertyType
- ThePropertyType
of thePropertyTree
we want to fetch- Returns:
- The PropertyTree or null if this PropertyTreeOwner does not manage a PropertyTree for the given PropertyType or if a null PropertyType is given
-
findPropConfig
-
initProperties
-
createPermissionModel
protected PropertyTreePermissionModel createPermissionModel(PropertyType scope, PropertyConfigCollection config) -
sendSessionKeepalive
protected void sendSessionKeepalive() -
updateSessionProps
Description copied from interface:InternalSession
Update the props and bindings associated with this session- Parameters:
config
- the session props config to apply
-
findPage
Description copied from interface:Session
Find thePage
associated with the given page ID- Parameters:
pageId
- the page ID associated with the target page- Returns:
- the page associated with the given page ID if it exists
-
getPages
- Returns:
- A list of all open pages for this session
-
getPageCount
public int getPageCount() -
getViewCount
public int getViewCount() -
getComponentCount
public int getComponentCount() -
getBindingCount
public int getBindingCount() -
getLocale
Description copied from interface:InternalSession
The current locale for this session, or a safe defaultLocale.getDefault()
if not available. -
getTimeZoneId
Description copied from interface:InternalSession
The current timezone id for this session, or a safe default if not available. -
onKeepaliveReceived
Description copied from interface:InternalSession
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
-
getPageReport
public com.inductiveautomation.ignition.common.gson.JsonArray getPageReport()Collects the "brief report " json structure of each running page in this session. -
getOrCreatePage
Returns a page for the given key, where the key itself is relevant to the session scope. For instance, the key used to get a page from a client project session will be a tab id. In the designer, each view open for editing is its own "session", and the designer derives a pageid based on the project resource id- Parameters:
pageId
- the page ID associated with the target page- Returns:
- an instantiated page with the matching key.
-
newPage
-
onSessionInit
public void onSessionInit(com.inductiveautomation.ignition.common.gson.JsonObject sessionInitResponse) Called when handling the session-init message. Gives the project session a chance to add things to the response- Parameters:
sessionInitResponse
- the response JSON object to be passed back to the client in response to the session-init call
-
receive
Description copied from interface:InternalSession
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
-
getKeepAliveIntervalSecs
public long getKeepAliveIntervalSecs() -
notifyConnected
Should notifyPageModel
s which are associated with this channel that the websocket has connected. May be used to determine that a client has established a first-time connection and requires the allocation and startup of view resources. This call may be re-entrant as socket connections are re-established.- Parameters:
channel
- the newly connected message channel that may provide any needed tab/session specific information
-
notifyDisconnected
Called when a message channel has disconnected.- Parameters:
channel
- the channel that was disconnected.
-
maybeScheduleReaper
protected abstract void maybeScheduleReaper()Call this when it's possible the last page has been closed. The session will then schedule the reaper to close the session itself (runtime sessions only, designer sessions don't reap in this way) -
closePage
Description copied from interface:InternalSession
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
Description copied from interface:InternalSession
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
-
visitPage
Description copied from interface:InternalSession
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
-
broadcast
Description copied from class:SessionKernelWrapper
Broadcast a message to all pages associated with this session- Specified by:
broadcast
in classSessionKernelWrapper<T extends SessionKernel>
- Parameters:
protocol
- the protocol of the message to broadcastpayload
- the payload of the message to broadcast
-
refreshBinding
Description copied from interface:Session
Refresh the binding for the given property- Parameters:
property
- the property which has the binding to refresh
-