| | |
| | | */
|
| | | public class HdlSocketHelper {
|
| | |
|
| | | private static final Long DEF_SEND_TIMEOUT = 500L;
|
| | | private static final Long DEF_SEND_TIMEOUT = 1000L;
|
| | | private static final int DEF_MAX_RETRY = 4;
|
| | | private static final int DEF_SEND_ONE = 1;
|
| | |
|
| | |
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | LogUtils.e("发送数据失败:" + e.getMessage());
|
| | | }
|
| | | } else {
|
| | | //超出重发次数并没有收到回复
|
| | |
| | | private void notifyFailure() {
|
| | | //移除监听
|
| | | removeListener();
|
| | | if (sendThread != null) {
|
| | | sendThread.shutdownNow();
|
| | | sendThread = null;
|
| | | }
|
| | | if (listener != null) {
|
| | | listener.onFailure();
|
| | | listener = null;
|
| | | try {
|
| | | if (sendThread != null) {
|
| | | sendThread.shutdownNow();
|
| | | sendThread = null;
|
| | | }
|
| | | if (listener != null) {
|
| | | listener.onFailure();
|
| | | listener = null;
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|