Examples of Nettosphere


Examples of org.atmosphere.nettosphere.Nettosphere

                    }

                }).build();

        Nettosphere server = new Nettosphere.Builder().config(config).build();
        assertNotNull(server);
        server.start();

        final CountDownLatch latch = new CountDownLatch(5);
        final AtomicReference<Set> response = new AtomicReference<Set>(new HashSet());
        AtmosphereClient client = ClientFactory.getDefault().newClient(AtmosphereClient.class);

        RequestBuilder request = client.newRequestBuilder()
                .method(Request.METHOD.GET)
                .uri(targetUrl + "/suspend")
                .transport(Request.TRANSPORT.LONG_POLLING);

        final Socket socket = client.create(client.newOptionsBuilder().build());

        final CountDownLatch suspendedLatch = new CountDownLatch(1);

        socket.on(new Function<Integer>() {
            @Override
            public void on(Integer statusCode) {
                suspendedLatch.countDown();
            }
        }).on("message", new Function<String>() {
            @Override
            public void on(String message) {
                logger.info("received : {}", message);
                response.get().add(message);
                latch.countDown();
            }
        }).on(new Function<Throwable>() {
            @Override
            public void on(Throwable t) {
                t.printStackTrace();
            }
        }).open(request.build());

        suspendedLatch.await(5, TimeUnit.SECONDS);

        socket.fire("ECHO1");
        socket.fire("ECHO2");
        socket.fire("ECHO3");
        socket.fire("ECHO4");
        socket.fire("ECHO5");

        latch.await(10, TimeUnit.SECONDS);

        assertEquals(response.get().size(), 5);
        socket.close();
        server.stop();

    }
View Full Code Here

Examples of org.atmosphere.nettosphere.Nettosphere

                    }

                }).build();

        Nettosphere server = new Nettosphere.Builder().config(config).build();
        assertNotNull(server);
        server.start();

        final CountDownLatch latch = new CountDownLatch(1);
        final AtomicBoolean hasEchoReplied = new AtomicBoolean(false);
        AtmosphereClient client = ClientFactory.getDefault().newClient(AtmosphereClient.class);
View Full Code Here

Examples of org.atmosphere.nettosphere.Nettosphere

                .initParam(DISABLE_ATMOSPHEREINTERCEPTOR, "true")
                .interceptor(new SwaggerSocketProtocolInterceptor())
                .port(8080)
                .host("127.0.0.1")
                .build();
        Nettosphere s = new Nettosphere.Builder().config(b.build()).build();
        s.start();
        String a = "";

        logger.info("NettoSphere Twitter Search started on port {}", 8080);
        logger.info("Type quit to stop the server");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.