aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/vaadin/shared/ui/root/RootState.java8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java38
2 files changed, 46 insertions, 0 deletions
diff --git a/src/com/vaadin/shared/ui/root/RootState.java b/src/com/vaadin/shared/ui/root/RootState.java
index 26844cba32..31c5a8f872 100644
--- a/src/com/vaadin/shared/ui/root/RootState.java
+++ b/src/com/vaadin/shared/ui/root/RootState.java
@@ -8,6 +8,7 @@ import com.vaadin.shared.Connector;
public class RootState extends ComponentState {
private Connector content;
+ private int heartbeatInterval;
public Connector getContent() {
return content;
@@ -17,4 +18,11 @@ public class RootState extends ComponentState {
this.content = content;
}
+ public int getHeartbeatInterval() {
+ return heartbeatInterval;
+ }
+
+ public void setHeartbeatInterval(int heartbeatInterval) {
+ this.heartbeatInterval = heartbeatInterval;
+ }
} \ No newline at end of file
diff --git a/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java b/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
index 7b5097ff77..a4740bdc64 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
@@ -11,10 +11,16 @@ import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Position;
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.http.client.RequestException;
+import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
@@ -71,6 +77,14 @@ public class RootConnector extends AbstractComponentContainerConnector
com.google.gwt.user.client.Window.setTitle(title);
}
});
+ final int heartbeatInterval = getState().getHeartbeatInterval();
+ new Timer() {
+ @Override
+ public void run() {
+ sendHeartbeat();
+ schedule(heartbeatInterval);
+ }
+ }.schedule(heartbeatInterval);
}
@Override
@@ -428,4 +442,28 @@ public class RootConnector extends AbstractComponentContainerConnector
});
}
+ private void sendHeartbeat() {
+ RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "url");
+
+ rb.setCallback(new RequestCallback() {
+
+ @Override
+ public void onResponseReceived(Request request, Response response) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onError(Request request, Throwable exception) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+
+ try {
+ rb.send();
+ } catch (RequestException re) {
+
+ }
+ }
}