org.richfaces.application.push

## Interface Session

- All Known Subinterfaces:
    DestroyableSession
  All Known Implementing Classes:
    SessionImpl

      public interface Session

  Session represents user’s subscription to a set of topics. This set is immutable, so new session should be created if user wants to add/remove subscriptions to some topics.

  Session does multiplexing for messages from several topics, so that only a single client connection is required to for data transfer.

  When session is created, it is getting unique UUID identifier, that client uses to communicate to that session.

  When client is subscribed to a set of topics associated with some session, session fires SessionPreSubscriptionEvent, so that application developer can control subscriptions according to access rights.

  Session is kept alive for (`getMaxInactiveInterval()`) minutes since the last time it has been accessed. Note that push can work in either polling (long polling) and persistent connection (WebSocket) modes, so session should be kept-alive correctly in both cases.

  Author:
    Nick Belaevski

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearBroadcastedMessages(long sequenceNumber)` Clears all the queues messages associated with this session that has sequence number lower than provided number
    `void` | `connect(Request request)` Connects given request to this session
    `void` | `disconnect()` Releases/disconnects associated request from this session
    `Map<TopicKey,String>` | `getFailedSubscriptions()` Get a map of topic keys this session failed to be subscribed to including the message why the subscription failed
    `String` | `getId()` Returns unique identifier of this session.
    `long` | `getLastAccessedTime()` Returns the last time when the session was accessed
    `int` | `getMaxInactiveInterval()` How much minutes is session kept alive since the last time it has been accessed before it is destroyed
    `Collection<MessageData>` | `getMessages()` Returns list of messages associated with this push session
    `Collection<TopicKey>` | `getSuccessfulSubscriptions()` Get a list of topic keys this session is successfully subscribed to
    `void` | `invalidate()` Invalidates this session, making it non-active
    `void` | `push(TopicKey topicKey, String serializedData)` Pushes given data to given topic key
    `void` | `subscribe(String[] topics)` Subscribe this session to given topics

- - ### Method Detail

    - #### getId

          String getId()

      Returns unique identifier of this session.

    - #### getMaxInactiveInterval

          int getMaxInactiveInterval()

      How much minutes is session kept alive since the last time it has been accessed before it is destroyed

    - #### getLastAccessedTime

          long getLastAccessedTime()

      Returns the last time when the session was accessed

    - #### getSuccessfulSubscriptions

          Collection<TopicKey> getSuccessfulSubscriptions()

      Get a list of topic keys this session is successfully subscribed to

    - #### getFailedSubscriptions

          Map<TopicKey,String> getFailedSubscriptions()

      Get a map of topic keys this session failed to be subscribed to including the message why the subscription failed

    - #### subscribe

          void subscribe(String[] topics)

      Subscribe this session to given topics

    - #### connect

          void connect(Request request)
                       throws Exception

      Connects given request to this session
      Throws:
        `Exception`

    - #### disconnect

          void disconnect()
                          throws Exception

      Releases/disconnects associated request from this session
      Throws:
        `Exception`

    - #### invalidate

          void invalidate()

      Invalidates this session, making it non-active

    - #### push

          void push(TopicKey topicKey,
                  String serializedData)

      Pushes given data to given topic key

    - #### getMessages

          Collection<MessageData> getMessages()

      Returns list of messages associated with this push session

    - #### clearBroadcastedMessages

          void clearBroadcastedMessages(long sequenceNumber)

      Clears all the queues messages associated with this session that has sequence number lower than provided number

Copyright © 2015 JBoss by Red Hat. All Rights Reserved.