2013-10-06 16 views
1

消息没有传递给服务器时,有办法处理情况吗?海豚日志记录的情况很清楚,但我想从代码中看到它。我一直在寻找像一些方法:的onError覆盖像onFinished如何解决OpenDolphin客户端发送HttpHostConnectException?

clientDolphin.send(message, new OnFinishedHandlerAdapter() { 
     @Override 
     public void onFinished(List<ClientPresentationModel> presentationModels) { 
      // Do something useful 
      } 
     } 
    }); 

,但有一点也不像。也包装发送在try/catch中的调用不起作用(因为send没有阻止其调用者代码,所以不会起作用)。

我的确有一些简单的方法来获得有关未传递的消息的信息,但我无法看到它。 Thaks,在advace,寻求答案!

回答

1

您可以为ClientConnector分配一个onException处理程序 - 而且您实际上应该这样做。异常处理程序将获取在异步发送操作中发生的异常对象。

下面是默认的处理程序,即使告诉你,你应该做的;-)

Closure onException = { Throwable up -> 
    def out = new StringWriter() 
    up.printStackTrace(new PrintWriter(out)) 
    log.severe("onException reached, rethrowing in UI Thread, consider setting ClientConnector.onException\n${out.buffer}") 
    uiThreadHandler.executeInsideUiThread { throw up } // not sure whether this is a good default 
} 
+0

谢谢Dierk。我已经做出了非常丑陋的解决方法:发送空消息,并等待响应几秒钟后出现。它作为心跳分开运行。但使用正确的解决方案肯定是一个更好的主意;)非常感谢! –

相关问题