Example usage for org.apache.wicket.util.time Time elapsedSince

List of usage examples for org.apache.wicket.util.time Time elapsedSince

Introduction

In this page you can find the example usage for org.apache.wicket.util.time Time elapsedSince.

Prototype

public Duration elapsedSince() 

Source Link

Document

Calculates the amount of time that has elapsed since this Time value.

Usage

From source file:org.wicketstuff.chat.channel.TimerChannelBehavior.java

License:Apache License

public static boolean isConnected(final Application application, final String id, final Duration timeout) {
    final Time time = TimerChannelBehavior.getLastPollEvent(application, id);
    boolean isConnected;
    if (time == null) {
        // the behavior has been cleaned
        return false;
    }/*from  ww w  .  ja v  a 2s.co m*/
    isConnected = time.elapsedSince().compareTo(timeout) < 0;
    if (!isConnected) {
        // timeout expired, the page is probably not connected anymore

        // we clean the metadata to avoid memory leak
        TimerChannelBehavior.cleanMetadata(application, id);
    }
    return isConnected;
}