Interface InternalSession

    • Method Detail

      • startup

        void startup()
        Start up the session.
        Throws:
        java.lang.IllegalStateException - if the session has already been started or shutdown
      • shutdown

        void shutdown()
        Shut down the session.
        Throws:
        java.lang.IllegalStateException - if the session has not been started or if it has already been shut down
      • isRunning

        boolean isRunning()
        Returns:
        true if the session has started and has not yet been shut down
      • notifyConnected

        void notifyConnected​(MessageChannel channel)
        Let the session know that the page has connected
        Parameters:
        channel - the MessageChannel used for communications between the client page and the gateway page
      • notifyDisconnected

        void notifyDisconnected​(MessageChannel channel)
        Let the session know that the page has disconnected
        Parameters:
        channel - the MessageChannel 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

        void receive​(MessageChannel channel,
                     java.lang.String protocol,
                     java.io.Reader payload)
        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
      • getOrCreatePage

        PageModel getOrCreatePage​(java.lang.String pageId)
        Fetch the PageModel 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

        java.util.Optional<PageModel> findPage​(java.lang.String pageId)
        Description copied from interface: Session
        Find the Page associated with the given page ID
        Specified by:
        findPage in interface Session
        Parameters:
        pageId - the page ID associated with the target page
        Returns:
        the page associated with the given page ID if it exists
      • getPages

        java.util.List<PageModel> getPages()
        Specified by:
        getPages in interface Session
        Returns:
        A list of all open pages for this session
      • closePage

        void closePage​(java.lang.String pageId)
        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

        void closePage​(java.lang.String pageId,
                       @Nullable
                       java.lang.String message)
        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
      • 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

        java.util.Optional<java.lang.String> logout()
        Logout of this session. The user will no longer be authenticated.
        Returns:
        a logout token or hint for the IdP if one is available
      • onLoginResponse

        void onLoginResponse​(WebAuthResponseContext webAuthResponseContext)
        Called when the session receives a login response from the IdP
        Parameters:
        webAuthResponseContext - the login response object
      • onLogoutResponse

        void onLogoutResponse​(WebAuthResponseContext webAuthResponseContext)
        Called when this session received a logout response from the IdP
        Parameters:
        webAuthResponseContext - the logout response object
      • scope

        default SessionScope scope()
        Description copied from interface: Session
        The scope in which this context represents -- Client or Designer
        Specified by:
        scope in interface Session
      • getLocale

        java.util.Locale getLocale()
        The current locale for this session, or a safe default Locale.getDefault() if not available.
      • getTimeZoneId

        java.lang.String getTimeZoneId()
        The current timezone id for this session, or a safe default if not available.
      • getTimeZone

        default java.util.TimeZone getTimeZone()
        The current timezone for this session, or a safe default if not available.
      • onKeepaliveReceived

        void onKeepaliveReceived​(java.lang.String pageId,
                                 long timestamp)
        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
      • updateSessionProps

        void updateSessionProps​(SessionPropsConfig config)
        Update the props and bindings associated with this session
        Parameters:
        config - the session props config to apply
      • getProject

        @Nonnull
        default PerspectiveProject getProject()
        Fetch the project associated with this session.
        Returns:
        the PerspectiveProject associated with this session
        Throws:
        java.lang.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.
      • getUptime

        long getUptime​(java.util.concurrent.TimeUnit timeUnit)
        Return the amount of time elapsed in the given time unit since the session started up.
        Parameters:
        timeUnit - the TimeUnit to which the internal startup time should be converted
        Returns:
        the up time in the given unit
      • getLastComm

        long getLastComm​(java.util.concurrent.TimeUnit timeUnit)
        Return the time in the given time unit when the last communication was received from the client
        Parameters:
        timeUnit - the TimeUnit to which the last communication time should be converted
        Returns:
        the last communication time in the given unit
      • getSessionClosedMessage

        java.lang.String getSessionClosedMessage()
        Returns:
        the default message sent to the client when the session is closed
      • getPageClosedMessage

        java.lang.String getPageClosedMessage()
        Returns:
        the default message sent to the client then a page is closed
      • close

        default void close​(@Nullable
                           java.lang.String message)
        Description copied from interface: Session
        Destroys this session and moves clients to a terminal state of closed
        Specified by:
        close in interface Session
        Parameters:
        message - the message displayed to the client on the terminal state page
      • createAccessToken

        java.lang.String createAccessToken()
        Create a new access token for this session. The access token expires in 30 seconds.
        Returns:
        the new short-lived access token used to establish a web socket connection
      • claimAccessToken

        boolean claimAccessToken​(java.lang.String token)
        Claim the given access token previously created by this session.
        Parameters:
        token - the access token to claim
        Returns:
        true if the access token is valid (not expired). false otherwise