TbWebSocketHandler refactoring

This commit is contained in:
YevhenBondarenko 2021-03-05 18:17:35 +02:00
parent e3851dcaad
commit 69025ab3af

View File

@ -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) {