在 GWT 中处理连接超时

发布于 2024-09-02 16:29:28 字数 176 浏览 2 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流年已逝 2024-09-09 16:29:28

RequestCallback .sendRequest(或只是send()) 抛出 RequestException - 我的猜测是这是失败点无网络连接的情况下。此外,<传递给 send(Request) 方法的 code>RequestCallback 还有一个 onError 方法如下:

当请求不存在时调用
正常完成。一个
RequestTimeoutException 就是一个例子
请求的错误类型
可能会遇到。

您可能应该自己做一些测试,看看何时抛出 RequestException 异常以及何时控制到达 onError - 尽管通常您使用相同的代码/方法来处理这两种情况,所以哪个处理什么可能并不重要,只是它们一起处理所有事情:)

RequestCallback.sendRequest (or just send()) throws RequestException - my guess would be that this is the point of failure in case of no net connection. Additionally, the RequestCallback you pass to the send(Request) method also has an onError method which is:

Called when a Request does not
complete normally. A
RequestTimeoutException is one example
of the type of error that a request
may encounter.

You should probably do some testing yourself to see when the RequestException exception is being thrown and when the control gets to onError - 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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文