public class AtmospherePushConnection extends Object implements PushConnection
PushConnection implementation that uses Atmosphere for
handling the communication channel.| Modifier and Type | Class and Description |
|---|---|
static class |
AtmospherePushConnection.AbstractJSO
JavaScriptObject class with some helper methods to set and get primitive
values.
|
static class |
AtmospherePushConnection.AtmosphereConfiguration
Class which provides information from the Atmosphere configuration
object.
|
static class |
AtmospherePushConnection.AtmosphereResponse
Class providing data from an Atmosphere response JavaScript object.
|
protected static class |
AtmospherePushConnection.FragmentedMessage
A class for splitting a message into multiple fragments of maximum length
AtmospherePushConnection.FragmentedMessage.FRAGMENT_LENGTH. |
protected static class |
AtmospherePushConnection.State
Represents the connection state of a push connection.
|
| Constructor and Description |
|---|
AtmospherePushConnection(Registry registry)
Creates a new instance connected to the given registry.
|
| Modifier and Type | Method and Description |
|---|---|
protected AtmospherePushConnection.AtmosphereConfiguration |
createConfig()
Creates the default Atmosphere configuration object.
|
void |
disconnect(Command command)
Closes the push connection.
|
protected AtmospherePushConnection.AtmosphereConfiguration |
getConfig() |
String |
getTransportType()
Returns a human readable string representation of the transport type used
to communicate with the server.
|
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)
Called when the Atmosphere client side timeout occurs.
|
protected void |
onClose(AtmospherePushConnection.AtmosphereResponse response)
Called when the push connection has been closed.
|
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)
Called whenever a message is received by Atmosphere.
|
protected void |
onOpen(AtmospherePushConnection.AtmosphereResponse response) |
protected void |
onReconnect(com.google.gwt.core.client.JavaScriptObject request,
AtmospherePushConnection.AtmosphereResponse response)
Called when the push connection has lost the connection to the server and
will proceed to try to re-establish the connection.
|
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.
|
public AtmospherePushConnection(Registry registry)
registry - the global registrypublic boolean isActive()
PushConnectionPushConnection.disconnect(Command) has been called.isActive in interface PushConnectiontrue if this connection can accept new messages;
false if this connection is disconnected or
disconnecting.public boolean isBidirectional()
PushConnectionisBidirectional in interface PushConnectionpublic void push(elemental.json.JsonObject message)
PushConnectionPushConnection.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)
push in interface PushConnectionmessage - the payload to pushPushConnection.isActive()protected AtmospherePushConnection.AtmosphereConfiguration getConfig()
protected void onReopen(AtmospherePushConnection.AtmosphereResponse response)
protected void onOpen(AtmospherePushConnection.AtmosphereResponse response)
protected void onConnect(AtmospherePushConnection.AtmosphereResponse response)
response - the responsepublic final void disconnect(Command command)
PushConnection
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.
disconnect in interface PushConnectioncommand - command to invoke when the connection has been properly
disconnectedprotected void onMessage(AtmospherePushConnection.AtmosphereResponse response)
response - the Atmosphere response object, which contains the messageprotected void onTransportFailure()
protected void onError(AtmospherePushConnection.AtmosphereResponse response)
Atmosphere will automatically retry the connection until successful.
response - the Atmosphere response for the failed connectionprotected void onClose(AtmospherePushConnection.AtmosphereResponse response)
This does not necessarily indicate an error and Atmosphere might try to reconnect or downgrade to the fallback transport automatically.
response - the Atmosphere response which was closedprotected void onClientTimeout(AtmospherePushConnection.AtmosphereResponse response)
The connection will be closed at this point and reconnect will not happen automatically.
response - the Atmosphere response which was used when the timeout
occurredprotected void onReconnect(com.google.gwt.core.client.JavaScriptObject request,
AtmospherePushConnection.AtmosphereResponse response)
request - the Atmosphere requestresponse - the Atmosphere responseprotected final AtmospherePushConnection.AtmosphereConfiguration createConfig()
public String getTransportType()
PushConnectiongetTransportType in interface PushConnectionCopyright © 2000–2018 Vaadin Ltd. All rights reserved.