Browse Source

TbWebSocketHandler refactoring

pull/4212/head
YevhenBondarenko 6 years ago
parent
commit
69025ab3af
  1. 3
      application/src/main/java/org/thingsboard/server/controller/plugin/TbWebSocketHandler.java

3
application/src/main/java/org/thingsboard/server/controller/plugin/TbWebSocketHandler.java

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

Loading…
Cancel
Save