com.vaadin.client.communication
Class AtmospherePushConnection

java.lang.Object
  extended by com.vaadin.client.communication.AtmospherePushConnection
All Implemented Interfaces:
PushConnection

public class AtmospherePushConnection
extends java.lang.Object
implements PushConnection

The default PushConnection implementation that uses Atmosphere for handling the communication channel.

Since:
7.1
Author:
Vaadin Ltd

Nested Class Summary
static class AtmospherePushConnection.AbstractJSO
           
static class AtmospherePushConnection.AtmosphereConfiguration
           
static class AtmospherePushConnection.AtmosphereResponse
           
protected static class AtmospherePushConnection.FragmentedMessage
          Represents a message that should be sent as multiple fragments.
protected static class AtmospherePushConnection.State
           
 
Constructor Summary
AtmospherePushConnection()
           
 
Method Summary
protected  AtmospherePushConnection.AtmosphereConfiguration createConfig()
           
 void disconnect(Command command)
          Closes the push connection.
protected  AtmospherePushConnection.AtmosphereConfiguration getConfig()
           
 java.lang.String getTransportType()
          Returns a human readable string representation of the transport type used to communicate with the server.
 void init(ApplicationConnection connection, com.vaadin.shared.ui.ui.UIState.PushConfigurationState pushConfiguration)
          Two-phase construction to allow using GWT.create().
 boolean isActive()
          Checks whether this push connection is in a state where it can push messages to the server.
 boolean isBidirectional()
          Checks whether this push connection should be used for communication in both directions or if an XHR should be used for client to server communication.
protected  void onClientTimeout(AtmospherePushConnection.AtmosphereResponse response)
           
protected  void onClose(AtmospherePushConnection.AtmosphereResponse response)
           
protected  void onConnect(AtmospherePushConnection.AtmosphereResponse response)
          Called whenever a server push connection is established (or re-established).
protected  void onError(AtmospherePushConnection.AtmosphereResponse response)
          Called if the push connection fails.
protected  void onMessage(AtmospherePushConnection.AtmosphereResponse response)
           
protected  void onOpen(AtmospherePushConnection.AtmosphereResponse response)
           
protected  void onReconnect(JavaScriptObject request, AtmospherePushConnection.AtmosphereResponse response)
           
protected  void onReopen(AtmospherePushConnection.AtmosphereResponse response)
           
protected  void onTransportFailure()
          Called if the transport mechanism cannot be used and the fallback will be tried
 void push(elemental.json.JsonObject message)
          Pushes a message to the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AtmospherePushConnection

public AtmospherePushConnection()
Method Detail

init

public void init(ApplicationConnection connection,
                 com.vaadin.shared.ui.ui.UIState.PushConfigurationState pushConfiguration)
Description copied from interface: PushConnection
Two-phase construction to allow using GWT.create().

Specified by:
init in interface PushConnection
Parameters:
connection - The ApplicationConnection

isActive

public boolean isActive()
Description copied from interface: PushConnection
Checks whether this push connection is in a state where it can push messages to the server. A connection is active until PushConnection.disconnect(Command) has been called.

Specified by:
isActive in interface PushConnection
Returns:
true if this connection can accept new messages; false if this connection is disconnected or disconnecting.

isBidirectional

public boolean isBidirectional()
Description copied from interface: PushConnection
Checks whether this push connection should be used for communication in both directions or if an XHR should be used for client to server communication. A bidirectional push connection must be able to reliably inform about its connection state.

Specified by:
isBidirectional in interface PushConnection
Returns:
true if the push connection should be used for messages in both directions, false if it should only be used for server to client messages

push

public void push(elemental.json.JsonObject message)
Description copied from interface: PushConnection
Pushes a message to the server. Will throw an exception if the connection is not active (see PushConnection.isActive()).

Implementation detail: If the push connection is not connected and the message can thus not be sent, the implementation must call ConnectionStateHandler.pushNotConnected(JsonObject), which will retry the send later.

This method must not be called if the push connection is not bidirectional (if PushConnection.isBidirectional() returns false)

Specified by:
push in interface PushConnection
Parameters:
message - the payload to push
See Also:
PushConnection.isActive()

getConfig

protected AtmospherePushConnection.AtmosphereConfiguration getConfig()

onReopen

protected void onReopen(AtmospherePushConnection.AtmosphereResponse response)

onOpen

protected void onOpen(AtmospherePushConnection.AtmosphereResponse response)

onConnect

protected void onConnect(AtmospherePushConnection.AtmosphereResponse response)
Called whenever a server push connection is established (or re-established).

Parameters:
response -
Since:
7.2

disconnect

public void disconnect(Command command)
Description copied from interface: PushConnection
Closes the push connection. To ensure correct message delivery order, new messages should not be sent using any other channel until it has been confirmed that all messages pending for this connection have been delivered. The provided command callback is invoked when messages can be passed using some other communication channel.

After this method has been called, PushConnection.isActive() returns false. Calling this method for a connection that is no longer active will throw an exception.

Specified by:
disconnect in interface PushConnection
Parameters:
command - callback command invoked when the connection has been properly disconnected

onMessage

protected void onMessage(AtmospherePushConnection.AtmosphereResponse response)

onTransportFailure

protected void onTransportFailure()
Called if the transport mechanism cannot be used and the fallback will be tried


onError

protected void onError(AtmospherePushConnection.AtmosphereResponse response)
Called if the push connection fails. Atmosphere will automatically retry the connection until successful.


onClose

protected void onClose(AtmospherePushConnection.AtmosphereResponse response)

onClientTimeout

protected void onClientTimeout(AtmospherePushConnection.AtmosphereResponse response)

onReconnect

protected void onReconnect(JavaScriptObject request,
                           AtmospherePushConnection.AtmosphereResponse response)

createConfig

protected AtmospherePushConnection.AtmosphereConfiguration createConfig()

getTransportType

public java.lang.String getTransportType()
Description copied from interface: PushConnection
Returns a human readable string representation of the transport type used to communicate with the server.

Specified by:
getTransportType in interface PushConnection
Returns:
A human readable string representation of the transport type


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.