Commit 69025ab3af5c0eb9bda7f2fe67e60a1314e8b211

Authored by YevhenBondarenko
1 parent e3851dca

TbWebSocketHandler refactoring

@@ -63,6 +63,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements Telemetr @@ -63,6 +63,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements Telemetr
63 63
64 private static final ConcurrentMap<String, SessionMetaData> internalSessionMap = new ConcurrentHashMap<>(); 64 private static final ConcurrentMap<String, SessionMetaData> internalSessionMap = new ConcurrentHashMap<>();
65 private static final ConcurrentMap<String, String> externalSessionMap = new ConcurrentHashMap<>(); 65 private static final ConcurrentMap<String, String> externalSessionMap = new ConcurrentHashMap<>();
  66 + private static final ByteBuffer PING_MSG = ByteBuffer.wrap(new byte[]{});
66 67
67 @Autowired 68 @Autowired
68 private TelemetryWebSocketService webSocketService; 69 private TelemetryWebSocketService webSocketService;
@@ -212,7 +213,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements Telemetr @@ -212,7 +213,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements Telemetr
212 synchronized void sendPing(long currentTime) { 213 synchronized void sendPing(long currentTime) {
213 try { 214 try {
214 if (currentTime - lastActivityTime >= pingTimeout) { 215 if (currentTime - lastActivityTime >= pingTimeout) {
215 - this.asyncRemote.sendPing(ByteBuffer.wrap(new byte[]{})); 216 + this.asyncRemote.sendPing(PING_MSG);
216 lastActivityTime = currentTime; 217 lastActivityTime = currentTime;
217 } 218 }
218 } catch (Exception e) { 219 } catch (Exception e) {