com.vaadin.flow.server.communication.
Class AtmospherePushConnection
- java.lang.Object
-
- com.vaadin.flow.server.communication.AtmospherePushConnection
-
All Implemented Interfaces:
public class AtmospherePushConnection extends Object implements PushConnection
A
PushConnection
implementation using the Atmosphere push support that is by default included in Vaadin.Since:
1.0
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description protected static class
AtmospherePushConnection.FragmentedMessage
Represents a message that can arrive as multiple fragments.
protected static class
AtmospherePushConnection.State
-
Constructor Summary
Constructors Constructor and Description AtmospherePushConnection(UI ui)
Creates an instance connected to the given UI.
-
Method Summary
All Methods Modifier and Type Method and Description void
connect(org.atmosphere.cpr.AtmosphereResource resource)
Associates this
AtmospherePushConnection
with the givenAtmosphereResource
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 String
getAtmosphereVersion()
Gets the Atmosphere version in use, as reported by
Version.getRawVersion()
.protected org.atmosphere.cpr.AtmosphereResource
getResource()
protected AtmospherePushConnection.State
getState()
Returns the state of this connection.
protected UI
getUI()
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 Reader
receiveMessage(Reader reader)
Reads and buffers a (possibly partial) message.
protected void
sendMessage(String message)
Sends the given message to the current client.
-
-
-
Constructor Detail
-
AtmospherePushConnection
public AtmospherePushConnection(UI ui)
Creates an instance connected to the given UI.
Parameters:
ui
- the UI to which this connection belongs
-
-
Method Detail
-
getAtmosphereVersion
public static String getAtmosphereVersion()
Gets the Atmosphere version in use, as reported by
Version.getRawVersion()
.Returns:
the Atmosphere version in use or null if Atmosphere was not found
-
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 interfacePushConnection
-
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(String message)
Sends the given message to the current client. Cannot be called if
isConnected()
returns false.Parameters:
message
- The message to send
-
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 a
Reader
yielding the complete message. Otherwise, returns null.Parameters:
reader
- A Reader from which to read the (partial) messageReturns:
A Reader yielding a complete message or null if the message is not yet complete.
Throws:
IOException
- if an IO error occurred
-
isConnected
public boolean isConnected()
Description copied from interface:
PushConnection
Returns whether this connection is currently open.
Specified by:
isConnected
in interfacePushConnection
Returns:
true if the connection is open, false otherwise
-
connect
public void connect(org.atmosphere.cpr.AtmosphereResource resource)
Associates this
AtmospherePushConnection
with the givenAtmosphereResource
representing an established push connection. If already connected, callsdisconnect()
first. If there is a deferred push, carries it out via the new connection.Parameters:
resource
- the resource to associate this connection with
-
getUI
protected UI getUI()
Returns:
the UI associated with this connection.
-
getResource
protected org.atmosphere.cpr.AtmosphereResource getResource()
Returns:
The AtmosphereResource associated with this connection or null if connection not open.
-
disconnect
public void disconnect()
Description copied from interface:
PushConnection
Closes the connection. Cannot be called if
PushConnection.isConnected()
is false.Specified by:
disconnect
in interfacePushConnection
-
connectionLost
public void connectionLost()
Called when the connection to the client has been lost.
-
getState
protected AtmospherePushConnection.State getState()
Returns the state of this connection.
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.
-
-