Sync: code local unifié
Synchronisation du code source local (fait foi). Signed-off-by: lions dev Team
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package dev.lions.unionflow.server.service;
|
||||
|
||||
import io.quarkus.websockets.next.OpenConnections;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* Service de broadcast WebSocket pour les notifications temps réel du dashboard.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class WebSocketBroadcastService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(WebSocketBroadcastService.class);
|
||||
|
||||
@Inject
|
||||
OpenConnections openConnections;
|
||||
|
||||
/**
|
||||
* Broadcast un message à toutes les connexions WebSocket ouvertes.
|
||||
*/
|
||||
public void broadcast(String message) {
|
||||
LOG.debugf("Broadcasting message to %d connections", openConnections.stream().count());
|
||||
openConnections.forEach(connection -> connection.sendTextAndAwait(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast une mise à jour de statistiques.
|
||||
*/
|
||||
public void broadcastStatsUpdate(String jsonData) {
|
||||
broadcast("{\"type\":\"stats_update\",\"data\":" + jsonData + "}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast une nouvelle activité.
|
||||
*/
|
||||
public void broadcastNewActivity(String jsonData) {
|
||||
broadcast("{\"type\":\"new_activity\",\"data\":" + jsonData + "}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast une mise à jour d'événement.
|
||||
*/
|
||||
public void broadcastEventUpdate(String jsonData) {
|
||||
broadcast("{\"type\":\"event_update\",\"data\":" + jsonData + "}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast une notification.
|
||||
*/
|
||||
public void broadcastNotification(String jsonData) {
|
||||
broadcast("{\"type\":\"notification\",\"data\":" + jsonData + "}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user