.map(chatroom -> ChatRoomInfoTo.from(chatroom));
}
- @GetMapping("list")
- public Mono<ChatRoomsTo> list()
- {
- return Arrays
- .stream(ownedShards)
- .mapToObj(shard -> chatHome.getChatRooms(shard))
- .map(chatroom -> ChatRoomInfoTo.from(chatroom));
- }
-
@GetMapping("{chatroomId}/list")
public Flux<MessageTo> list(@PathVariable UUID chatroomId)
{
public interface ChatHomeService
{
Mono<ChatRoom> getChatRoom(UUID id);
- Flux<ChatRoom> getChatRooms(int shard);
+ Flux<ChatRoom> getChatRooms();
}
}
@Override
- public Flux<ChatRoom> getChatRooms(int shard)
+ public Flux<ChatRoom> getChatRooms()
{
- return Flux.fromStream(chatrooms[shard].values().stream());
+ return Flux
+ .fromIterable(ownedShards)
+ .flatMap(shard -> chatrooms[shard].values().stream());
}
}