}
TestListener testListener = new TestListener(port, chatRooms);
- CompletableFuture<Void> testListenerFuture = testListener
+ testListener
.run()
- .toFuture();
+ .subscribe(message -> log.info(
+ "Received message: {}",
+ message));
log.info("Sleeping for 3 seconds...");
Thread.sleep(3000);
testWriterFutures[i].join();
log.info("Joined TestWriter {}", testWriters[i].user);
}
-
-
- log.info("Sleeping for 3 seconds...");
- Thread.sleep(3000);
- log.info("Joining TestListener...");
- testListener.running = false;
- testListenerFuture.join();
- log.info("Joined TestListener");
}
Mono<ChatRoomInfoTo> createChatRoom(String name)
static final ParameterizedTypeReference<ServerSentEvent<String>> SSE_TYPE = new ParameterizedTypeReference<>() {};
- public Mono<Void> run()
+ public Flux<MessageTo> run()
{
return Flux
.fromArray(chatRooms)
message);
});
})
- .limitRate(10)
.takeUntil(message -> !running)
- .doOnComplete(() -> log.info("TestListener is done"))
- .parallel(chatRooms.length)
- .runOn(Schedulers.parallel())
- .then();
+ .doOnComplete(() -> log.info("TestListener is done"));
}
Flux<ServerSentEvent<String>> receiveMessages(ChatRoomInfoTo chatRoom)