Micronaut

netty-socket-io.hostname=localhost
netty-socket-io.port=9092
netty-socket-io.ping-timeout=60000
netty-socket-io.ping-interval=25000

Main Application

@Singleton
public class MicronautMainApplication {
    
    @Inject
    SocketIOServer server;
    
    @EventListener
    void onStartup(ServerStartupEvent event) {
        // Add event listeners
        server.addEventListener("chatevent", ChatMessage.class, (client, data, ackRequest) -> {
            server.getBroadcastOperations().sendEvent("chatevent", data);
        });
        
        server.start();
        log.info("Socket.IO server started on port {}", server.getConfiguration().getPort());
    }
}

Event Handlers

Full Example

See the complete example in the netty-socketio-examples-micronaut-base module.

Last updated

Was this helpful?