Package com.vaadin.client.communication
Interface PushConnection
-
- All Known Implementing Classes:
AtmospherePushConnection
public interface PushConnectionRepresents 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 theApplicationConnection.- Since:
- 7.1
- Author:
- Vaadin Ltd
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddisconnect(com.google.gwt.user.client.Command command)Closes the push connection.StringgetTransportType()Returns a human readable string representation of the transport type used to communicate with the server.voidinit(ApplicationConnection connection, UIState.PushConfigurationState pushConfigurationState)Two-phase construction to allow using GWT.create().booleanisActive()Checks whether this push connection is in a state where it can push messages to the server.booleanisBidirectional()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.voidpush(elemental.json.JsonObject payload)Pushes a message to the server.
-
-
-
Method Detail
-
init
void init(ApplicationConnection connection, UIState.PushConfigurationState pushConfigurationState)
Two-phase construction to allow using GWT.create().- Parameters:
connection- The ApplicationConnection
-
push
void push(elemental.json.JsonObject payload)
Pushes a message to the server. Will throw an exception if the connection is not active (seeisActive()).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
isBidirectional()returns false)- Parameters:
payload- the payload to push- Throws:
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 untildisconnect(Command)has been called.- Returns:
trueif this connection can accept new messages;falseif this connection is disconnected or disconnecting.
-
disconnect
void disconnect(com.google.gwt.user.client.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()returnsfalse. 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:
IllegalStateException- if this connection is not active
-
getTransportType
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
-
isBidirectional
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. A bidirectional push connection must be able to reliably inform about its connection state.- 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
- Since:
- 7.6
-
-