Package com.vaadin.client.communication
Class MessageSender
java.lang.Object
com.vaadin.client.communication.MessageSender
MessageSender is responsible for sending messages to the server.
Internally uses XhrConnection and/or PushConnection for
delivering messages, depending on the application configuration.
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionMessageSender(Registry registry) Creates a new instance connected to the given registry. -
Method Summary
Modifier and TypeMethodDescriptionReturns a human readable string representation of the method used to communicate with the server.booleanvoidResynchronize the client side, i.e. reload all component hierarchy and state from the serverprotected 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) voidSends any pending invocations to the server if there is no request in progress and the application is running.voidvoidsetClientToServerMessageId(int nextExpectedId, boolean force) Used internally to update what id the server expects.voidsetPushEnabled(boolean enabled) Sets the status for the push connection.voidsetPushEnabled(boolean enabled, boolean reEnableIfNeeded) Sets the status for the push connection.
-
Constructor Details
-
MessageSender
Creates a new instance connected to the given registry.- Parameters:
registry- the global registry
-
-
Method Details
-
sendUnloadBeacon
public void sendUnloadBeacon() -
sendBeacon
-
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. Adds message to message queue and postpones sending if queue not empty.- 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.
-
setPushEnabled
public void setPushEnabled(boolean enabled, boolean reEnableIfNeeded) Sets the status for the push connection.- Parameters:
enabled-trueto enable the push connection;falseto disable the push connection.reEnableIfNeeded-trueif push should be re-enabled after disconnection if configuration changed;falseto prevent reconnection.
-
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
-
hasQueuedMessages
public boolean hasQueuedMessages()
-