From 543aff2a044d1d11cb4e2c587c73586224d06c00 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 20 Apr 2024 14:23:43 +0100 Subject: [PATCH] send metrics to client when they connect --- .../mcutils/backend/websocket/impl/MetricsWebSocket.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/xyz/mcutils/backend/websocket/impl/MetricsWebSocket.java b/src/main/java/xyz/mcutils/backend/websocket/impl/MetricsWebSocket.java index b4929af..45fb885 100644 --- a/src/main/java/xyz/mcutils/backend/websocket/impl/MetricsWebSocket.java +++ b/src/main/java/xyz/mcutils/backend/websocket/impl/MetricsWebSocket.java @@ -1,6 +1,7 @@ package xyz.mcutils.backend.websocket.impl; import lombok.extern.log4j.Log4j2; +import org.jetbrains.annotations.NotNull; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; import xyz.mcutils.backend.Main; @@ -30,6 +31,11 @@ public class MetricsWebSocket extends WebSocket { }, interval, interval); } + @Override + public void afterConnectionEstablished(@NotNull WebSocketSession session) { + sendMetrics(session); // Send metrics to the client when they connect + } + /** * Sends the metrics to the client. *