Class AbstractSession<T extends SessionKernel>

All Implemented Interfaces:
AuditingContext, LoggingContext, PerspectiveElement, PropertyTreeOwner, Session, InternalSession, SessionKernel
Direct Known Subclasses:
PerspectiveDesignSession, PerspectiveProjectSession

public abstract class AbstractSession<T extends SessionKernel> extends SessionKernelWrapper<T>
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.
  • Field Details

  • Method Details

    • getPropertyTreeOf

      @Nullable public PropertyTree getPropertyTreeOf(@Nullable PropertyType propertyType)
      Description copied from interface: PropertyTreeOwner
      Fetch the PropertyTree associated with the given PropertyType
      Parameters:
      propertyType - The PropertyType of the PropertyTree 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

      protected Optional<SessionPropsConfig> findPropConfig()
    • initProperties

      protected Map<PropertyType,PropertyTree> initProperties(SessionPropsConfig config)
    • createPermissionModel

      protected PropertyTreePermissionModel createPermissionModel(PropertyType scope, PropertyConfigCollection config)
    • sendSessionKeepalive

      protected void sendSessionKeepalive()
    • updateSessionProps

      public void updateSessionProps(SessionPropsConfig config)
      Description copied from interface: InternalSession
      Update the props and bindings associated with this session
      Parameters:
      config - the session props config to apply
    • findPage

      public Optional<PageModel> findPage(String pageId)
      Description copied from interface: Session
      Find the Page 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

      public List<PageModel> 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

      public Locale getLocale()
      Description copied from interface: InternalSession
      The current locale for this session, or a safe default Locale.getDefault() if not available.
    • getTimeZoneId

      public String getTimeZoneId()
      Description copied from interface: InternalSession
      The current timezone id for this session, or a safe default if not available.
    • onKeepaliveReceived

      public void onKeepaliveReceived(String pageId, long timestamp)
      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 request
      timestamp - 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

      @Nonnull public PageModel getOrCreatePage(@Nonnull String pageId)
      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

      @Nonnull protected PageModel newPage(@Nonnull String pageId)
    • 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

      public void receive(MessageChannel channel, String protocol, Reader payload)
      Description copied from interface: InternalSession
      Called when this session has received a message from the message channel.
      Parameters:
      channel - the MessageChannel from which the message was received
      protocol - the protocol of the message
      payload - the payload of the message
    • getKeepAliveIntervalSecs

      public long getKeepAliveIntervalSecs()
    • notifyConnected

      public void notifyConnected(MessageChannel channel)
      Should notify PageModels 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

      public void notifyDisconnected(MessageChannel channel)
      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

      public void closePage(String pageId)
      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

      public void closePage(String pageId, @Nullable String message)
      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 page
      message - the message displayed to the client on the terminal state page
    • visitPage

      public void visitPage(String pageId, InternalSession.PageVisitor visitor)
      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 ID
      visitor - the page visitor
    • broadcast

      protected void broadcast(String protocol, String payload)
      Description copied from class: SessionKernelWrapper
      Broadcast a message to all pages associated with this session
      Specified by:
      broadcast in class SessionKernelWrapper<T extends SessionKernel>
      Parameters:
      protocol - the protocol of the message to broadcast
      payload - the payload of the message to broadcast
    • refreshBinding

      public void refreshBinding(PropertyKey property)
      Description copied from interface: Session
      Refresh the binding for the given property
      Parameters:
      property - the property which has the binding to refresh