org.richfaces.application.push.impl

## Class RequestImpl

- java.lang.Object
- - org.richfaces.application.push.impl.RequestImpl

- All Implemented Interfaces:
    org.atmosphere.cpr.AtmosphereResourceEventListener, org.atmosphere.cpr.AtmosphereResourceHeartbeatEventListener, Request

      public class RequestImpl
      extends Object
      implements Request, org.atmosphere.cpr.AtmosphereResourceEventListener

  Current implementation of Request wraps AtmosphereResource class.

  Request connects to push session to have messages written to the client and provides MessageListener interfacefor that. Current implementation of Session connects provided MessageListener to JMS bus. Also request connection notifies session manager about session activity, so that it is marked active and disconnection sets session manager to start session expiration counter.

  Author:
    Nick Belaevski, Lukas Fryc

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RequestImpl(org.atmosphere.cpr.Meteor meteor, Session session)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Session` | `getSession()` Returns a user push session associated with this request
    `boolean` | `isPolling()` Returns true if this request represents long-polling request
    `void` | `onBroadcast(org.atmosphere.cpr.AtmosphereResourceEvent event)` This method is called once the broadcast event occurs.
    `void` | `onClose(org.atmosphere.cpr.AtmosphereResourceEvent atmosphereResourceEvent)`
    `void` | `onDisconnect(org.atmosphere.cpr.AtmosphereResourceEvent event)`
    `void` | `onHeartbeat(org.atmosphere.cpr.AtmosphereResourceEvent atmosphereResourceEvent)`
    `void` | `onPreSuspend(org.atmosphere.cpr.AtmosphereResourceEvent atmosphereResourceEvent)`
    `void` | `onResume(org.atmosphere.cpr.AtmosphereResourceEvent event)`
    `void` | `onSuspend(org.atmosphere.cpr.AtmosphereResourceEvent event)`
    `void` | `onThrowable(org.atmosphere.cpr.AtmosphereResourceEvent event)`
    `void` | `postMessages()` Tries to push messages, when there are some in the session's queue.
    `void` | `resume()` Resume the underlying response object
    `void` | `suspend()` suspends an underlying response object

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RequestImpl

          public RequestImpl(org.atmosphere.cpr.Meteor meteor,
                             Session session)

  - ### Method Detail

    - #### suspend

          public void suspend()

      Description copied from interface: `Request`
      suspends an underlying response object
      Specified by:
        `suspend` in interface `Request`

    - #### resume

          public void resume()

      Description copied from interface: `Request`
      Resume the underlying response object
      Specified by:
        `resume` in interface `Request`

    - #### isPolling

          public boolean isPolling()

      Description copied from interface: `Request`
      Returns true if this request represents long-polling request
      Specified by:
        `isPolling` in interface `Request`

    - #### getSession

          public Session getSession()

      Description copied from interface: `Request`
      Returns a user push session associated with this request
      Specified by:
        `getSession` in interface `Request`

    - #### postMessages

          public void postMessages()

      Tries to push messages, when there are some in the session's queue.

      When detects that request is currently broadcasting, it ignores the call, since the sending of the messages will be proceed later as stated by `onBroadcast(AtmosphereResourceEvent)` method.

      Specified by:
        `postMessages` in interface `Request`

    - #### onPreSuspend

          public void onPreSuspend(org.atmosphere.cpr.AtmosphereResourceEvent atmosphereResourceEvent)

      Specified by:
        `onPreSuspend` in interface `org.atmosphere.cpr.AtmosphereResourceEventListener`

    - #### onClose

          public void onClose(org.atmosphere.cpr.AtmosphereResourceEvent atmosphereResourceEvent)

      Specified by:
        `onClose` in interface `org.atmosphere.cpr.AtmosphereResourceEventListener`

    - #### onHeartbeat

          public void onHeartbeat(org.atmosphere.cpr.AtmosphereResourceEvent atmosphereResourceEvent)

      Specified by:
        `onHeartbeat` in interface `org.atmosphere.cpr.AtmosphereResourceHeartbeatEventListener`

    - #### onSuspend

          public void onSuspend(org.atmosphere.cpr.AtmosphereResourceEvent event)

      Specified by:
        `onSuspend` in interface `org.atmosphere.cpr.AtmosphereResourceEventListener`

    - #### onResume

          public void onResume(org.atmosphere.cpr.AtmosphereResourceEvent event)

      Specified by:
        `onResume` in interface `org.atmosphere.cpr.AtmosphereResourceEventListener`

    - #### onDisconnect

          public void onDisconnect(org.atmosphere.cpr.AtmosphereResourceEvent event)

      Specified by:
        `onDisconnect` in interface `org.atmosphere.cpr.AtmosphereResourceEventListener`

    - #### onBroadcast

          public void onBroadcast(org.atmosphere.cpr.AtmosphereResourceEvent event)

      This method is called once the broadcast event occurs.

      Once this event occurs, he broadcasting is done, so we can clean up.

      This method clears the broadcasted messages from session and then opens the request for further broadcasting.

      In case this request is long-polling, the request is completed and client needs to start new request for receiving new messages.

      In another case - the request is done by websocket - it tries to send messages which could be posted when broadcasting.

      Specified by:
        `onBroadcast` in interface `org.atmosphere.cpr.AtmosphereResourceEventListener`

    - #### onThrowable

          public void onThrowable(org.atmosphere.cpr.AtmosphereResourceEvent event)

      Specified by:
        `onThrowable` in interface `org.atmosphere.cpr.AtmosphereResourceEventListener`

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