Class AtmospherePushConnection

  • All Implemented Interfaces:
    PushConnection, java.io.Serializable

    public class AtmospherePushConnection
    extends java.lang.Object
    implements PushConnection
    A PushConnection implementation using the Atmosphere push support that is by default included in Vaadin.
    Since:
    7.1
    Author:
    Vaadin Ltd
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void connect​(org.atmosphere.cpr.AtmosphereResource resource)
      Associates this AtmospherePushConnection with the given AtmosphereResource representing an established push connection.
      void connectionLost()
      Called when the connection to the client has been lost.
      void disconnect()
      Closes the connection.
      static void enableAtmosphereDebugLogging()
      Internal method used for reconfiguring loggers to show all Atmosphere log messages in the console.
      static java.lang.String getAtmosphereVersion()  
      org.atmosphere.cpr.AtmosphereResource getResource()
      Gets the atmosphere resource associated with this connection.
      protected AtmospherePushConnection.State getState()
      Returns the state of this connection.
      UI getUI()
      Gets the UI this push connection is associated with.
      boolean isConnected()
      Returns whether this connection is currently open.
      void push()
      Pushes pending state changes and client RPC calls to the client.
      void push​(boolean async)
      Pushes pending state changes and client RPC calls to the client.
      protected java.io.Reader receiveMessage​(java.io.Reader reader)
      Reads and buffers a (possibly partial) message.
      protected void sendMessage​(java.lang.String message)
      Sends the given message to the current client.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AtmospherePushConnection

        public AtmospherePushConnection​(UI ui)
    • Method Detail

      • getAtmosphereVersion

        public static java.lang.String getAtmosphereVersion()
      • push

        public void push()
        Description copied from interface: PushConnection
        Pushes pending state changes and client RPC calls to the client. Can be called even if PushConnection.isConnected() is false; the push will be deferred until a connection is available. It is NOT safe to invoke this method if not holding the session lock.

        This is internal API; please use UI.push() instead.

        Specified by:
        push in interface PushConnection
      • push

        public void push​(boolean async)
        Pushes pending state changes and client RPC calls to the client. If isConnected() is false, defers the push until a connection is established.
        Parameters:
        async - True if this push asynchronously originates from the server, false if it is a response to a client request.
      • sendMessage

        protected void sendMessage​(java.lang.String message)
        Sends the given message to the current client. Cannot be called if isConnected() is false.
        Parameters:
        message - The message to send
      • receiveMessage

        protected java.io.Reader receiveMessage​(java.io.Reader reader)
                                         throws java.io.IOException
        Reads and buffers a (possibly partial) message. If a complete message was received, or if the call resulted in the completion of a partially received message, returns a Reader yielding the complete message. Otherwise, returns null.
        Parameters:
        reader - A Reader from which to read the (partial) message
        Returns:
        A Reader yielding a complete message or null if the message is not yet complete.
        Throws:
        java.io.IOException
      • isConnected

        public boolean isConnected()
        Description copied from interface: PushConnection
        Returns whether this connection is currently open.
        Specified by:
        isConnected in interface PushConnection
      • connect

        public void connect​(org.atmosphere.cpr.AtmosphereResource resource)
        Associates this AtmospherePushConnection with the given AtmosphereResource representing an established push connection. If already connected, calls disconnect() first. If there is a deferred push, carries it out via the new connection.
        Since:
        7.2
      • getUI

        public UI getUI()
        Gets the UI this push connection is associated with.
        Returns:
        the UI associated with this connection
      • getResource

        public org.atmosphere.cpr.AtmosphereResource getResource()
        Gets the atmosphere resource associated with this connection.
        Returns:
        The AtmosphereResource associated with this connection or null if the connection is not open.
      • connectionLost

        public void connectionLost()
        Called when the connection to the client has been lost.
        Since:
        7.4.1
      • enableAtmosphereDebugLogging

        public static void enableAtmosphereDebugLogging()
        Internal method used for reconfiguring loggers to show all Atmosphere log messages in the console.
        Since:
        7.6