Quarkus
netty-socket-io.hostname=localhost
netty-socket-io.port=9092
netty-socket-io.ping-timeout=60000
netty-socket-io.ping-interval=25000netty-socket-io :
hostname : localhost
port : 9092
ping-timeout : 60000
ping-interval : 25000
Application principale
@ApplicationScoped
public class QuarkusMainApplication {
@Inject
SocketIOServer server;
void onStart(@Observes StartupEvent ev) {
// Ajouter des écouteurs d'événements
server.addEventListener("chatevent", ChatMessage.class, (client, data, ackRequest) -> {
server.getBroadcastOperations().sendEvent("chatevent", data);
});
server.start();
log.info("Serveur Socket.IO démarré sur le port {}", server.getConfiguration().getPort());
}
void onStop(@Observes ShutdownEvent ev) {
server.stop();
}
}
Gestionnaires d'événements
Exemple complet
Mis à jour
Ce contenu vous a-t-il été utile ?