From 23a46b4be35277e06ec89f48730eeb694e686be8 Mon Sep 17 00:00:00 2001
From: Kenmegne <stephanie.kenmegne@gmail.com>
Date: Thu, 18 Jun 2026 15:40:06 +0000
Subject: [PATCH] add fdx-commons and fdx-consultation

---
 fdx-consultation/fdxconsultation-service-impl/src/main/java/com/megatim/fdxconsultation/service/impl/sockets/StandaloneServerStateEndpoint.java |   64 ++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/fdx-consultation/fdxconsultation-service-impl/src/main/java/com/megatim/fdxconsultation/service/impl/sockets/StandaloneServerStateEndpoint.java b/fdx-consultation/fdxconsultation-service-impl/src/main/java/com/megatim/fdxconsultation/service/impl/sockets/StandaloneServerStateEndpoint.java
new file mode 100644
index 0000000..9af36d2
--- /dev/null
+++ b/fdx-consultation/fdxconsultation-service-impl/src/main/java/com/megatim/fdxconsultation/service/impl/sockets/StandaloneServerStateEndpoint.java
@@ -0,0 +1,64 @@
+package com.megatim.fdxconsultation.service.impl.sockets;
+
+import com.megatim.fdxconsultation.core.ifaces.supervision.StandaloneServerStateEntityManager;
+import com.megatim.fdxconsultation.model.supervision.StandaloneServerStateEntity;
+import com.megatim.fdxconsultation.service.impl.sockets.encoders.StandaloneServerStateEntityDecoder;
+import com.megatim.fdxconsultation.service.impl.sockets.encoders.StandaloneServerStateEntityEncoder;
+import com.megatim.fdxconsultation.service.impl.sockets.helpers.StandaloneServerStateSessionHandler;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.inject.Inject;
+import javax.websocket.EncodeException;
+import javax.websocket.OnClose;
+import javax.websocket.OnError;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
+import javax.websocket.Session;
+import javax.websocket.server.ServerEndpoint;
+
+/**
+ *
+ * @author lenovo
+ */
+@ServerEndpoint(value = "/standalone-server-state",
+        encoders = {StandaloneServerStateEntityEncoder.class},
+        decoders = {StandaloneServerStateEntityDecoder.class}
+)
+public class StandaloneServerStateEndpoint {
+
+    @Inject
+    private StandaloneServerStateSessionHandler standaloneServerStateSessionHandler;
+
+    @Inject
+    private StandaloneServerStateEntityManager standaloneServerStateEntityManager;
+
+    @OnOpen
+    public void onOpen(Session session) {
+
+        if (standaloneServerStateEntityManager.getCurrentStandaloneServerStateEntity() != null) {
+            try {
+                session.getBasicRemote().sendObject(standaloneServerStateEntityManager.getCurrentStandaloneServerStateEntity());
+            } catch (IOException | EncodeException ex) {
+                Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+
+        standaloneServerStateSessionHandler.addSession(session);
+    }
+
+    @OnMessage
+    public void onMessage(StandaloneServerStateEntity message, Session session) {
+    }
+
+    @OnClose
+    public void onClose(Session session) {
+        standaloneServerStateSessionHandler.removeSession(session);
+    }
+
+    @OnError
+    public void onError(Session session, Throwable throwable) {
+        standaloneServerStateSessionHandler.removeSession(session);
+    }
+
+}

--
Gitblit v1.10.0