Pārlūkot izejas kodu

link manage adjust

chudk 7 gadi atpakaļ
vecāks
revīzija
239166664b

+ 4 - 4
src/main/java/com/tidecloud/dataacceptance/service/impl/DiscardServerHandler.java

@@ -50,7 +50,7 @@ public class DiscardServerHandler extends ChannelInboundHandlerAdapter {
     
     public static Map<String, String> channelMap = new HashMap<String, String>();
     public static Map<String, Channel> manageChannelMap = new HashMap<>();
-    public static Map<Channel, String> channelMapOfChannelKey = new HashMap<>();
+    public static Map<String, Channel> channelMapOfChannelKey = new HashMap<>();
     public static Map<String, String> commandCopy = new HashMap<>();
     
     @Autowired
@@ -73,8 +73,8 @@ public class DiscardServerHandler extends ChannelInboundHandlerAdapter {
         String deviceId = advice.getDeviceId();
         String adviceType = advice.getAdviceType();
         Channel channel = ctx.channel();
-        String deviceIdInMap = channelMapOfChannelKey.get(channel);
-        if (deviceIdInMap == null) {
+        Channel channelInMap = channelMapOfChannelKey.get(deviceId);
+        if (channelInMap == null) {
             manageLink(channel, deviceId);
         }
         switch (adviceType) {
@@ -106,7 +106,7 @@ public class DiscardServerHandler extends ChannelInboundHandlerAdapter {
         String channelId = UUID.randomUUID().toString();
         manageChannelMap.put(channelId, channel);
         channelMap.put(channelId, deviceId);
-        channelMapOfChannelKey.put(channel, deviceId);
+        channelMapOfChannelKey.put(deviceId, channel);
         logger.info("链接管理,链接id [{}]", channelId);
         
         ConnectMsg cMsg = new ConnectMsg("10.27.118.76", channelId);

+ 2 - 0
src/main/java/com/tidecloud/dataacceptance/web/WatchController.java

@@ -32,7 +32,9 @@ public class WatchController {
         }
         Channel channel = channelMap.get(socketId);
         try {
+            logger.info("start write command to device");
             channel.writeAndFlush(commandStr);
+            logger.info("end write command to device");
         } catch (Exception e) {
             logger.error(e.getLocalizedMessage());
         }