在 GWT 中处理连接超时
我正在使用 GWT 和 PHP,并且通过 RequestBuilder
类进行通信, 但我需要处理是否存在互联网连接并显示一些消息 但是 RequestBuilder
类支持 RequestCallback
接口,无法处理互联网 连接是否存在。解决办法是什么?
I am using GWT and PHP and communication is via the RequestBuilder
class,
but I need to handle internet connection present or not and show some message
but RequestBuilder
class supports RequestCallback
interface which cannot handle internet
connection present or not. What is the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
RequestCallback .sendRequest
(或只是send()
) 抛出RequestException
- 我的猜测是这是失败点无网络连接的情况下。此外,<传递给 send(Request) 方法的 code>RequestCallback 还有一个onError
方法如下:您可能应该自己做一些测试,看看何时抛出
RequestException
异常以及何时控制到达onError
- 尽管通常您使用相同的代码/方法来处理这两种情况,所以哪个处理什么可能并不重要,只是它们一起处理所有事情:)RequestCallback.sendRequest
(or justsend()
) throwsRequestException
- my guess would be that this is the point of failure in case of no net connection. Additionally, theRequestCallback
you pass to the send(Request) method also has anonError
method which is:You should probably do some testing yourself to see when the
RequestException
exception is being thrown and when the control gets toonError
- although, usually you use the same code/method to handle both cases, so it might not matter which handles what, just that together they handle everything :)