Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

空き部屋数取得の実装 #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apiServer/src/main/protobuf/room.proto
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ message SendResultRequest {
repeated Coordinate ghostRecord = 3;
}

message GetPublicRoomResponse {
int32 vagrantRoom = 1;
}

message Empty {}

service RoomService {
Expand All @@ -94,6 +98,9 @@ service RoomService {
rpc ParentOperation(ParentOperationRequest) returns (stream Operation) {};

rpc SendResult(SendResultRequest) returns (Empty) {};

// まだ埋まっていない公開部屋数
rpc GetPublicRoom(Empty) returns (GetPublicRoomResponse) {};
}


Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

}