| | |
| | |
|
| | | private final IClient client;
|
| | | private IHeartbeat iHeartbeat;
|
| | |
|
| | | public void SetHeartbeat(IHeartbeat iHeartbeat){
|
| | | this.iHeartbeat=iHeartbeat;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 当前接收到数据的时间
|
| | | */
|
| | |
| | | /**
|
| | | * 记录所有SocketBoot
|
| | | */
|
| | | final static List<TcpSocketBoot> TCP_SOCKET_BOOT_LIST = new ArrayList();
|
| | | final static List<TcpSocketBoot> TCP_SOCKET_BOOT_LIST = new ArrayList<>();
|
| | |
|
| | | /**
|
| | | * 根据IP地址及端口获取当前socketBoot
|
| | | *
|
| | | * @param ipAddress
|
| | | * @param port
|
| | | * @return
|
| | |
| | | return null;
|
| | | }
|
| | | for(TcpSocketBoot tcpSocketBoot : TCP_SOCKET_BOOT_LIST){
|
| | | if(ipAddress.equals(tcpSocketBoot.getClient().getOptions().getIp())&& tcpSocketBoot.getClient().getOptions().getPort()==port)
|
| | | {
|
| | | if (ipAddress.equals(tcpSocketBoot.getClient().getOptions().getIp()) && tcpSocketBoot.getClient().getOptions().getPort() == port) {
|
| | | return tcpSocketBoot;
|
| | | }
|
| | | }
|
| | |
| | | public void run() {
|
| | | while (true) {
|
| | | try {
|
| | | if(connected==false){
|
| | | if (!connected) {
|
| | | Thread.sleep(100);
|
| | | continue;
|
| | | }
|
| | |
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 重新连接
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 发送无需回调
|
| | | *
|
| | | * @param msg 发送的数据
|
| | | */
|
| | | public void sendMsg(byte[] msg) {
|
| | |
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | // /**
|
| | | // * 断开全部的Link网关连接
|
| | | // */
|
| | | // public static void stopAllConnectLinkGateway() {
|
| | | // for (TcpSocketBoot data : TCP_SOCKET_BOOT_LIST) {
|
| | | // //断开指定的link网关连接
|
| | | // stopConnectLinkGateway(data);
|
| | | // }
|
| | | //
|
| | | // }
|
| | | //
|
| | | // /**
|
| | | // * 断开指定的link网关连接
|
| | | // *
|
| | | // * @param tcpSocketBoot tcp对象
|
| | | // */
|
| | | // public static void stopConnectLinkGateway(TcpSocketBoot tcpSocketBoot) {
|
| | | // synchronized (TCP_SOCKET_BOOT_LIST) {
|
| | | // try {
|
| | | // TCP_SOCKET_BOOT_LIST.remove(tcpSocketBoot);
|
| | | // tcpSocketBoot.client.disconnect();
|
| | | // } catch (Exception ignored) {
|
| | | // }
|
| | | // }
|
| | | // }
|
| | |
|
| | | }
|