Micronaut
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
@Singleton
public class MicronautMainApplication {
@Inject
SocketIOServer server;
@EventListener
void onStartup(ServerStartupEvent event) {
// 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());
}
}
Gestionnaires d'événements
Exemple complet
Mis à jour
Ce contenu vous a-t-il été utile ?