GWT - 如果服务器更新,客户端如何检测到它的 javascript 不同步
我有一个 GWT 应用程序,用户可以无限期地保持应用程序基于浏览器的一侧打开。我们经常升级应用程序 - 如果用户在完成此操作后在浏览器中点击重新加载,那么一切都会正常。然而,通常发生的情况是,他们继续使用已经打开的应用程序版本,即升级之前提供的版本,然后遇到与 RPC 相关的模糊错误,因为客户端 Javascript 不再与服务器上的同步。
GWT 是否有任何可以启用或合并到代码中的机制来处理此问题。我不需要对这种情况进行任何巧妙的处理,例如尝试重新加载应用程序并重新建立用户的当前状态,一个简单的对话框解释客户端和服务器不再同步并且需要重新加载 Web 应用程序就足够了。
I have a GWT application where users keep the browser based side of the application open indefinitely. Every so often we upgrade the application - if the users hit reload in their browsers after this is done then everything goes fine. However what usually happens is that they carry on using the already open version of the application, i.e. a version served before the upgrade, and then experience obscure RPC related errors as the client side Javascript is no longer in sync with what is on the server.
Does GWT have any mechanism, that you can enable or incorporate in your code, for coping with this. I don't need any clever handling of the situation, e.g. trying to reload the application and reestablish the user's current state, a simple dialog explaining that client and server are no longer in sync and that the web application needs to be reloaded would be enough.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
接口文档
com.google.gwt.user.client.rpc.AsyncCallback
给出了如何执行此操作的提示。您很可能想要处理(弹出用户对话框)
IncompleteRemoteServiceException
。The documentation of the interface
com.google.gwt.user.client.rpc.AsyncCallback<T>
gives a hint on how to do this.You most likely want to handle (pop-up the user dialog) the
IncompatibleRemoteServiceException
.它称为 IncompleteRemoteServiceException,以及如何处理包括此在内的异常,在Google的与服务器通信文档。
It is called IncompatibleRemoteServiceException, and how to handle exceptions including this one is mentioned in the Google's Communicating with a Server Documentation.