com.vaadin.client.communication
Interface PushConnection

All Known Implementing Classes:
AtmospherePushConnection

public interface PushConnection

Represents the client-side endpoint of a bidirectional ("push") communication channel. Can be used to send UIDL request messages to the server and to receive UIDL messages from the server (either asynchronously or as a response to a UIDL request.) Delegates the UIDL handling to the ApplicationConnection.

Since:
7.1
Author:
Vaadin Ltd

Method Summary
 void disconnect(Command command)
          Closes the push connection.
 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 pushConfigurationState, ApplicationConnection.CommunicationErrorHandler errorHandler)
          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.
 void push(JSONObject payload)
          Pushes a message to the server.
 

Method Detail

init

void init(ApplicationConnection connection,
          com.vaadin.shared.ui.ui.UIState.PushConfigurationState pushConfigurationState,
          ApplicationConnection.CommunicationErrorHandler errorHandler)
Two-phase construction to allow using GWT.create().

Parameters:
connection - The ApplicationConnection

push

void push(JSONObject payload)
Pushes a message to the server. Will throw an exception if the connection is not active (see isActive()).

Implementation detail: The implementation is responsible for queuing messages that are pushed after #init(ApplicationConnection) has been called but before the connection has internally been set up and then replay those messages in the original order when the connection has been established.

Parameters:
payload - the payload to push
Throws:
java.lang.IllegalStateException - if this connection is not active
See Also:
isActive()

isActive

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

Returns:
true if this connection can accept new messages; false if this connection is disconnected or disconnecting.

disconnect

void disconnect(Command command)
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, isActive() returns false. Calling this method for a connection that is no longer active will throw an exception.

Parameters:
command - callback command invoked when the connection has been properly disconnected
Throws:
java.lang.IllegalStateException - if this connection is not active

getTransportType

java.lang.String getTransportType()
Returns a human readable string representation of the transport type used to communicate with the server.

Returns:
A human readable string representation of the transport type
Since:
7.1


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