| | |
| | | try {
|
| | | LogUtils.i("TCP连接");
|
| | | client.onConnectStatus(ConnectStatus.CONNECTING);
|
| | | Thread.sleep(700);
|
| | | Thread.sleep(1000);
|
| | | client.connect();
|
| | | connected=true;
|
| | | LogUtils.i("TCP连接成功");
|
| | | client.onConnectStatus(ConnectStatus.CONNECTED);
|
| | | }catch(Exception e) {
|
| | | LogUtils.e("连接异常"+e.getMessage());
|
| | |
| | | }
|
| | | Thread.sleep(3*1000);
|
| | | } catch (Exception e) {
|
| | |
|
| | | LogUtils.e("定时连接失败:" + e.getMessage());
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | if (connected && 10 * 1000 < (System.currentTimeMillis() - time)) {
|
| | | time = System.currentTimeMillis();
|
| | | //心跳检测
|
| | | try {
|
| | | if (iHeartbeat != null)
|
| | | iHeartbeat.heartbeat();
|
| | | } catch (Exception e) {
|
| | | }
|
| | | if (iHeartbeat != null)
|
| | | iHeartbeat.heartbeat();
|
| | | }
|
| | | Thread.sleep(1000);
|
| | | } catch (Exception e) {
|
| | |
|
| | | LogUtils.e("定时心跳检测网关异常:" + e.getMessage());
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | mMessageQueue.put(request);
|
| | | } catch (Exception e) {
|
| | |
|
| | | LogUtils.e("发送数据失败:" + e.getMessage());
|
| | | }
|
| | | }
|
| | |
|