其他示例程序

final Processor<Integer, Integer> keyboardStream = RingBufferProcessor.create();

NetStreams.<String, String>httpServer(spec ->
                spec
                        .codec(StandardCodecs.STRING_CODEC)
                        .listen(3000)
        )
        .ws("/", channel -> {
                System.out.println("Connected a websocket client: " + channel.remoteAddress());

                return Streams
                        .wrap(keyboardStream)
                        .skipWhile(key -> KeyEvent.VK_UP != key)
                        .buffer(10, 1) 
                        .map(keys -> keys.size() == 10 &&
                                keys.get(0) == KeyEvent.VK_UP &&
                                keys.get(1) == KeyEvent.VK_UP &&
                                keys.get(2) == KeyEvent.VK_DOWN &&
                                keys.get(3) == KeyEvent.VK_DOWN &&
                                keys.get(4) == KeyEvent.VK_LEFT &&
                                keys.get(5) == KeyEvent.VK_RIGHT &&
                                keys.get(6) == KeyEvent.VK_LEFT &&
                                keys.get(7) == KeyEvent.VK_RIGHT &&
                                keys.get(8) == KeyEvent.VK_B &&
                                keys.get(9) == KeyEvent.VK_A
                )
                .map(isKonami -> isKonami ? "Konami!" : "Nah")
                .nest()
                .flatMap(konamis ->
                        channel.writeWith(konamis)
                );
        })
        .start()
        .await();

keyboardStream.onNext(KeyEvent.VK_RIGHT);
keyboardStream.onNext(KeyEvent.VK_UP);
keyboardStream.onNext(KeyEvent.VK_UP);
keyboardStream.onNext(KeyEvent.VK_DOWN);
keyboardStream.onNext(KeyEvent.VK_DOWN);
keyboardStream.onNext(KeyEvent.VK_LEFT);
keyboardStream.onNext(KeyEvent.VK_RIGHT);
keyboardStream.onNext(KeyEvent.VK_LEFT);
keyboardStream.onNext(KeyEvent.VK_RIGHT);
keyboardStream.onNext(KeyEvent.VK_B);
keyboardStream.onNext(KeyEvent.VK_A);
keyboardStream.onNext(KeyEvent.VK_C);
keyboardStream.onComplete();

System.out.println(konamis.await());