send metrics to client when they connect

This commit is contained in:
Lee 2024-04-20 14:23:43 +01:00
parent b666e5a8b7
commit 543aff2a04

@ -1,6 +1,7 @@
package xyz.mcutils.backend.websocket.impl; package xyz.mcutils.backend.websocket.impl;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.WebSocketSession;
import xyz.mcutils.backend.Main; import xyz.mcutils.backend.Main;
@ -30,6 +31,11 @@ public class MetricsWebSocket extends WebSocket {
}, interval, interval); }, 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. * Sends the metrics to the client.
* *