Merge pull request #4212 from YevhenBondarenko/fix/ws

TbWebSocketHandler refactoring
This commit is contained in:
Igor Kulikov 2021-03-09 12:58:42 +02:00 committed by GitHub
commit d9a5ee6d0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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