import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
-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;
com.google.gwt.user.client.Window.setTitle(title);
}
});
- final int heartbeatInterval = getState().getHeartbeatInterval();
- new Timer() {
- @Override
- public void run() {
- sendHeartbeat();
- schedule(heartbeatInterval);
- }
- }.schedule(heartbeatInterval);
getWidget().addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
});
}
- 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) {
-
- }
- }
}
public class RootState extends ComponentState {
private Connector content;
- private int heartbeatInterval;
public Connector getContent() {
return content;
this.content = content;
}
- public int getHeartbeatInterval() {
- return heartbeatInterval;
- }
-
- public void setHeartbeatInterval(int heartbeatInterval) {
- this.heartbeatInterval = heartbeatInterval;
- }
}
\ No newline at end of file