import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
+import java.util.Arrays;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.IntStream;
Thread.sleep(2000);
+ Arrays
+ .stream(testClients)
+ .forEach(testClient -> testClient.running = false);
+
Flux
.fromArray(chatRooms)
- .flatMap(chatRoom ->receiveMessages(chatRoom).take(100))
+ .flatMap(chatRoom ->receiveMessages(chatRoom).take(2))
.doOnNext(message -> log.info("message: {}", message))
.then()
.block();
@Override
public void run()
{
- for (int i = 0; i < 100; i++)
+ for (int i = 0; running; i++)
{
String message = "Message #" + i;
for (ChatRoomInfoTo chatRoom : chatRooms)
private final ChatRoomInfoTo[] chatRooms;
private final User user;
+ volatile boolean running = true;
+
TestClient(Integer port, ChatRoomInfoTo[] chatRooms, String username)
{