Browse Source
Merge pull request #4212 from YevhenBondarenko/fix/ws
TbWebSocketHandler refactoring
pull/4220/head
Igor Kulikov
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
2 additions and
1 deletions
-
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, String> externalSessionMap = new ConcurrentHashMap<>(); |
|
|
|
private static final ByteBuffer PING_MSG = ByteBuffer.wrap(new byte[]{}); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TelemetryWebSocketService webSocketService; |
|
|
|
@ -212,7 +213,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements Telemetr |
|
|
|
synchronized void sendPing(long currentTime) { |
|
|
|
try { |
|
|
|
if (currentTime - lastActivityTime >= pingTimeout) { |
|
|
|
this.asyncRemote.sendPing(ByteBuffer.wrap(new byte[]{})); |
|
|
|
this.asyncRemote.sendPing(PING_MSG); |
|
|
|
lastActivityTime = currentTime; |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
|