Package com.vaadin.server.communication
Class AtmospherePushConnection
- java.lang.Object
-
- com.vaadin.server.communication.AtmospherePushConnection
-
- All Implemented Interfaces:
PushConnection,Serializable
public class AtmospherePushConnection extends Object implements PushConnection
APushConnectionimplementation using the Atmosphere push support that is by default included in Vaadin.- Since:
- 7.1
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAtmospherePushConnection.FragmentedMessageRepresents a message that can arrive as multiple fragments.protected static classAtmospherePushConnection.State
-
Constructor Summary
Constructors Constructor Description AtmospherePushConnection(UI ui)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect(org.atmosphere.cpr.AtmosphereResource resource)Associates thisAtmospherePushConnectionwith the givenAtmosphereResourcerepresenting an established push connection.voidconnectionLost()Called when the connection to the client has been lost.voiddisconnect()Closes the connection.static voidenableAtmosphereDebugLogging()Internal method used for reconfiguring loggers to show all Atmosphere log messages in the console.static StringgetAtmosphereVersion()org.atmosphere.cpr.AtmosphereResourcegetResource()Gets the atmosphere resource associated with this connection.protected AtmospherePushConnection.StategetState()Returns the state of this connection.UIgetUI()Gets the UI this push connection is associated with.booleanisConnected()Returns whether this connection is currently open.voidpush()Pushes pending state changes and client RPC calls to the client.voidpush(boolean async)Pushes pending state changes and client RPC calls to the client.protected ReaderreceiveMessage(Reader reader)Reads and buffers a (possibly partial) message.
-
-
-
Constructor Detail
-
AtmospherePushConnection
public AtmospherePushConnection(UI ui)
-
-
Method Detail
-
getAtmosphereVersion
public static String getAtmosphereVersion()
-
push
public void push()
Description copied from interface:PushConnectionPushes pending state changes and client RPC calls to the client. Can be called even ifPushConnection.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:
pushin interfacePushConnection
-
push
public void push(boolean async)
Pushes pending state changes and client RPC calls to the client. IfisConnected()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.
-
receiveMessage
protected Reader receiveMessage(Reader reader) throws 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 aReaderyielding 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:
IOException
-
isConnected
public boolean isConnected()
Description copied from interface:PushConnectionReturns whether this connection is currently open.- Specified by:
isConnectedin interfacePushConnection
-
connect
public void connect(org.atmosphere.cpr.AtmosphereResource resource)
Associates thisAtmospherePushConnectionwith the givenAtmosphereResourcerepresenting an established push connection. If already connected, callsdisconnect()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
nullif the connection is not open.
-
disconnect
public void disconnect()
Description copied from interface:PushConnectionCloses the connection. Cannot be called ifPushConnection.isConnected()is false.- Specified by:
disconnectin interfacePushConnection
-
connectionLost
public void connectionLost()
Called when the connection to the client has been lost.- Since:
- 7.4.1
-
getState
protected AtmospherePushConnection.State getState()
Returns the state of this connection.
-
enableAtmosphereDebugLogging
public static void enableAtmosphereDebugLogging()
Internal method used for reconfiguring loggers to show all Atmosphere log messages in the console.- Since:
- 7.6
-
-