Package com.vaadin.client.communication
Class MessageSender
- java.lang.Object
-
- com.vaadin.client.communication.MessageSender
-
public class MessageSender extends Object
MessageSender is responsible for sending messages to the server.Internally uses
XhrConnectionand/orPushConnectionfor delivering messages, depending on the application configuration.- Since:
- 1.0
- Author:
- Vaadin Ltd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMessageSender.ResynchronizationState
-
Constructor Summary
Constructors Constructor Description MessageSender(Registry registry)Creates a new instance connected to the given registry.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCommunicationMethodName()Returns a human readable string representation of the method used to communicate with the server.voidresynchronize()Resynchronize the client side, i.e.protected voidsend(elemental.json.JsonArray reqInvocations, elemental.json.JsonObject extraJson)Makes an UIDL request to the server.voidsend(elemental.json.JsonObject payload)Sends an asynchronous or synchronous UIDL request to the server using the given URI.static voidsendBeacon(String url, String payload)voidsendInvocationsToServer()Sends any pending invocations to the server if there is no request in progress and the application is running.voidsendUnloadBeacon()voidsetClientToServerMessageId(int nextExpectedId, boolean force)Used internally to update what id the server expects.voidsetPushEnabled(boolean enabled)Sets the status for the push connection.
-
-
-
Constructor Detail
-
MessageSender
public MessageSender(Registry registry)
Creates a new instance connected to the given registry.- Parameters:
registry- the global registry
-
-
Method Detail
-
sendUnloadBeacon
public void sendUnloadBeacon()
-
sendInvocationsToServer
public void sendInvocationsToServer()
Sends any pending invocations to the server if there is no request in progress and the application is running.If a request is in progress, this method does nothing and assumes that it is called again when the request completes.
-
send
protected void send(elemental.json.JsonArray reqInvocations, elemental.json.JsonObject extraJson)Makes an UIDL request to the server.- Parameters:
reqInvocations- Data containing RPC invocations and all related information.extraJson- Parameters that are added to the payload
-
send
public void send(elemental.json.JsonObject payload)
Sends an asynchronous or synchronous UIDL request to the server using the given URI.- Parameters:
payload- The contents of the request to send
-
setPushEnabled
public void setPushEnabled(boolean enabled)
Sets the status for the push connection.- Parameters:
enabled-trueto enable the push connection;falseto disable the push connection.
-
getCommunicationMethodName
public String getCommunicationMethodName()
Returns a human readable string representation of the method used to communicate with the server.- Returns:
- A string representation of the current transport type
-
resynchronize
public void resynchronize()
Resynchronize the client side, i.e. reload all component hierarchy and state from the server
-
setClientToServerMessageId
public void setClientToServerMessageId(int nextExpectedId, boolean force)Used internally to update what id the server expects.- Parameters:
nextExpectedId- the new client id to setforce- true if the id must be updated, false otherwise
-
-