Package io.reactivex.netty.protocol.text.sse

Examples of io.reactivex.netty.protocol.text.sse.ServerSentEvent


        return Observable.interval(interval, TimeUnit.MILLISECONDS)
                .flatMap(new Func1<Long, Observable<Void>>() {
                    @Override
                    public Observable<Void> call(Long interval) {
                        System.out.println("Writing SSE event for interval: " + interval);
                        return response.writeAndFlush(new ServerSentEvent(String.valueOf(interval), "notification", "hello " + interval));
                    }
                }).materialize()
                .takeWhile(new Func1<Notification<Void>, Boolean>() {
                    @Override
                    public Boolean call(Notification<Void> notification) {
View Full Code Here


    private Observable<Void> createReplyHandlerObservable(final HttpServerResponse<ServerSentEvent> response) {
        return Observable.interval(interval, TimeUnit.MILLISECONDS)
                .flatMap(new Func1<Long, Observable<Void>>() {
                    @Override
                    public Observable<Void> call(Long interval) {
                        ServerSentEvent data = new ServerSentEvent(
                                Long.toString(interval),
                                "data",
                                LogEvent.randomLogEvent(source).toCSV()
                        );
                        return response.writeAndFlush(data);
View Full Code Here

                                                   final HttpServerResponse<ServerSentEvent> response) {

                        return connectToLogProducers().flatMap(new Func1<ServerSentEvent, Observable<Void>>() {
                            @Override
                            public Observable<Void> call(ServerSentEvent sse) {
                                ServerSentEvent data = new ServerSentEvent(sse.getEventId(), "data", sse.getEventData());
                                return response.writeAndFlush(data);
                            }
                        }).onErrorResumeNext(new Func1<Throwable, Observable<Void>>() {
                            @Override
                            public Observable<Void> call(Throwable throwable) {
View Full Code Here

            logger.info("Turbine => SSE Request Received");
            response.getHeaders().setHeader("Content-Type", "text/event-stream");
            return publishedStreams
                    .doOnUnsubscribe(() -> logger.info("Turbine => Unsubscribing RxNetty server connection"))
                    .flatMap(data -> {
                        return response.writeAndFlush(new ServerSentEvent(null, null, JsonUtility.mapToJson(data)));
                    });
        }, PipelineConfigurators.<ByteBuf> sseServerConfigurator()).startAndWait();
    }
View Full Code Here

    public static void main(String args[]) {
        RxNetty.createHttpServer(8080, (request, response) -> {
            return Demo.getStream().flatMap(data -> {
                response.getHeaders().set("Content-Type", "text/event-stream");
                return response.writeAndFlush(new ServerSentEvent("1", "data", JsonUtility.mapToJson(data)));
            });
        }, PipelineConfigurators.sseServerConfigurator()).startAndWait();
    }
View Full Code Here

                });

        Object first = Observable.amb(objectObservable, Observable.timer(1000, TimeUnit.MILLISECONDS)).toBlockingObservable().first();

        assertTrue("Expected SSE message", first instanceof ServerSentEvent);
        ServerSentEvent sse = (ServerSentEvent) first;
        JsonNode jsonNode = mapper.readTree(sse.getEventData());
        assertEquals("Expected hystrix key name", HystrixCommandMetricsSamples.SAMPLE_1.getCommandKey().name(), jsonNode.get("name").asText());
    }
View Full Code Here

TOP

Related Classes of io.reactivex.netty.protocol.text.sse.ServerSentEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.