Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Using PUSH componenets (Atmosphere?)

florin ghe
1 decade ago Jan 30, 2010 6:17pm
Henri Muurimaa
1 decade ago Jan 31, 2010 10:49am
Sami Ekblad
1 decade ago Jan 31, 2010 11:20am
gustav trede
1 decade ago Jan 31, 2010 1:24pm
Joonas Lehtinen
1 decade ago Jan 31, 2010 4:39pm
Archie Cobbs
1 decade ago Feb 04, 2010 9:33pm

Joonas Lehtinen: #111 is not in roadmaps, but it should be. Unfortunately there has always been "more important things" that has pushed it from being included in roadmaps.

I'm new to Vaadin but from my understanding the current state of affairs is that to get server-generated events some sort of polling is required. Well, that's OK.. i.e., it's not the end of the world for many applications and suffices as a workaround until some form of "official" server push is implemented.

But given this state of affairs, Vaadin should have a more explicit way to do polling. From what I can tell the only way to do it now is the "progress meter hack". Instead of hacks buried in the forums, why not create a first class API for polling?

For example, something like:

/**
 * Instances cause clients to poll for server-generated events at a fixed interval.
 */
public class ClientPoller {

  /**
   * Create a poller that will poll every {@code millis} milliseconds.
   * Initially this instance will be stopped.
   *
   * @param millis polling interval in milliseconds
   */
  public ClientPoller(int millis) {
    ...
  }

  /**
   * Get the currently configured polling interval.
   *
   * @return polling interval in milliseconds
   */
  public int getInterval() {
    ...
  }

  /**
   * Change the currently configured polling interval.
   *
   * @param millis polling interval in milliseconds
   */
  public void setInterval(int millis) {
    ...
  }

  /**
   * Start polling. Does nothing if already started.
   */
  public void startPolling() {
    ...
  }

  /**
   * Stop polling. Does nothing if already stopped.
   */
  public void stopPolling() {
    ...
  }

  /**
   * Poll once for updates. Can be used for "ad hoc" polling.
   */
  public static void pollOnce() {
    ...
  }
}

In the implementation you would have a singleton class on the client that "collapses" the polling demands from all active ClientPoller instances. So for example if widget A creates and starts a 5 second instance, and then widget B creates and starts a 7 second instance, you would still end up polling only once every 5 seconds.

Should I file a feature request? :-)

Last updated on Feb, 5th 2010
Arthur S
1 decade ago May 19, 2010 11:17am
Joonas Lehtinen
1 decade ago May 19, 2010 11:26am
Arthur S
1 decade ago May 19, 2010 11:47am
Joonas Lehtinen
1 decade ago May 19, 2010 12:33pm
jasphior g
1 decade ago Apr 27, 2012 8:51am
Archie Cobbs
1 decade ago May 13, 2012 8:00pm