Commit d9a5ee6d0dacd4b71c43f4a44f676dd92131e096
Committed by
GitHub
Merge pull request #4212 from YevhenBondarenko/fix/ws
TbWebSocketHandler refactoring
Showing
1 changed file
with
2 additions
and
1 deletions
@@ -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) { |