我的应用程序的 onModuleLoad() 中有以下代码:
Window.addWindowClosingHandler(new ClosingHandler() {
@Override
public void onWindowClosing(ClosingEvent event) {
event.setMessage("If you choose to close, application will sign out");
}
});
//sign out on close
Window.addCloseHandler(new CloseHandler<Window>() {
@Override
public void onClose(CloseEvent<Window> event) {
sendLogout();
}
});
sendLogout() 函数如下所示:
// Set up the callback object.
AsyncCallback<String> callback = new LogoutCallback(this);
// Make the call to the survey service.
SurveySystemService.Util.getInstance().logout(details, callback);
“细节”是一些对象。
关闭窗口时它工作得很好,但是如果我尝试刷新页面,它不会注销。我的想法是,由于调用是异步的,因此在重新启动模块之前它没有完成将消息发送到服务器。
我尝试过: 1. 在 onClose 方法中创建和调用回调。2. 使用计时器检查是否拨打了电话。3. Endless loos 检查与上述相同(我绝望了)。
在所有这些解决方案中,程序都会到达回调创建,但服务器从未收到任何东西。
有什么帮助吗?