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 XhrConnection and/or PushConnection for delivering messages, depending on the application configuration.

Since:
1.0
Author:
Vaadin Ltd
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance connected to the given registry.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a human readable string representation of the method used to communicate with the server.
    boolean
     
    void
    Resynchronize the client side, i.e. reload all component hierarchy and state from the server
    protected void
    send(elemental.json.JsonArray reqInvocations, elemental.json.JsonObject extraJson)
    Makes an UIDL request to the server.
    void
    send(elemental.json.JsonObject payload)
    Sends an asynchronous or synchronous UIDL request to the server using the given URI.
    static void
    sendBeacon(String url, String payload)
     
    void
    Sends any pending invocations to the server if there is no request in progress and the application is running.
    void
     
    void
    setClientToServerMessageId(int nextExpectedId, boolean force)
    Used internally to update what id the server expects.
    void
    setPushEnabled(boolean enabled)
    Sets the status for the push connection.
    void
    setPushEnabled(boolean enabled, boolean reEnableIfNeeded)
    Sets the status for the push connection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MessageSender

      public MessageSender(Registry registry)
      Creates a new instance connected to the given registry.
      Parameters:
      registry - the global registry
  • Method Details

    • sendUnloadBeacon

      public void sendUnloadBeacon()
    • sendBeacon

      public static void sendBeacon(String url, String payload)
    • 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 - true to enable the push connection; false to disable the push connection.
    • setPushEnabled

      public void setPushEnabled(boolean enabled, boolean reEnableIfNeeded)
      Sets the status for the push connection.
      Parameters:
      enabled - true to enable the push connection; false to disable the push connection.
      reEnableIfNeeded - true if push should be re-enabled after disconnection if configuration changed; false to prevent reconnection.
    • 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 set
      force - true if the id must be updated, false otherwise
    • hasQueuedMessages

      public boolean hasQueuedMessages()