diff --git a/apiServer/src/main/protobuf/room.proto b/apiServer/src/main/protobuf/room.proto index e976555..2d753b9 100644 --- a/apiServer/src/main/protobuf/room.proto +++ b/apiServer/src/main/protobuf/room.proto @@ -81,6 +81,10 @@ message SendResultRequest { repeated Coordinate ghostRecord = 3; } +message GetPublicRoomResponse { + int32 vagrantRoom = 1; +} + message Empty {} service RoomService { @@ -94,6 +98,9 @@ service RoomService { rpc ParentOperation(ParentOperationRequest) returns (stream Operation) {}; rpc SendResult(SendResultRequest) returns (Empty) {}; + + // まだ埋まっていない公開部屋数 + rpc GetPublicRoom(Empty) returns (GetPublicRoomResponse) {}; } diff --git a/apiServer/src/main/scala/com/github/CA21engineer/HouseHackathonUnityServer/service/RoomAggregates.scala b/apiServer/src/main/scala/com/github/CA21engineer/HouseHackathonUnityServer/service/RoomAggregates.scala index 77ef62a..92ecab9 100644 --- a/apiServer/src/main/scala/com/github/CA21engineer/HouseHackathonUnityServer/service/RoomAggregates.scala +++ b/apiServer/src/main/scala/com/github/CA21engineer/HouseHackathonUnityServer/service/RoomAggregates.scala @@ -111,5 +111,12 @@ class RoomAggregates[T, Coordinate, Operation](implicit materializer: Materializ source } + def getPublicRoom: Int = { + this.rooms.count { room => + // 埋まっていない && パブリック + !room._2.isFull && room._2.roomKey.isEmpty + } + } + } diff --git a/apiServer/src/main/scala/com/github/CA21engineer/HouseHackathonUnityServer/service/RoomServicePowerApiImpl.scala b/apiServer/src/main/scala/com/github/CA21engineer/HouseHackathonUnityServer/service/RoomServicePowerApiImpl.scala index cd5cabc..7f5bffd 100644 --- a/apiServer/src/main/scala/com/github/CA21engineer/HouseHackathonUnityServer/service/RoomServicePowerApiImpl.scala +++ b/apiServer/src/main/scala/com/github/CA21engineer/HouseHackathonUnityServer/service/RoomServicePowerApiImpl.scala @@ -74,4 +74,10 @@ class RoomServicePowerApiImpl(implicit materializer: Materializer) extends RoomS } .fold(Future.failed[Empty](new Exception("Internal Error!!!")))(_ => Future.successful(Empty())) } + + // まだ埋まっていない公開部屋数 + override def getPublicRoom(in: Empty, metadata: Metadata): Future[GetPublicRoomResponse] = { + Future.successful(GetPublicRoomResponse(roomAggregates.getPublicRoom)) + } + }