Allow /rtc/validate to return room not found message (#1344)

It's not always possible for WebSocket clients to obtain status code or
error messages returned during WS Upgrade. Moving autocreation validation
to an explicit interface in the validation step so the /rtc/validate
would be able to return an appropriate message.
This commit is contained in:
David Zhao
2023-01-29 21:41:44 -08:00
committed by GitHub
parent 21f816d23c
commit 9a1f4ab18b
4 changed files with 105 additions and 17 deletions
+11
View File
@@ -117,6 +117,17 @@ func (r *StandardRoomAllocator) CreateRoom(ctx context.Context, req *livekit.Cre
return rm, nil
}
func (r *StandardRoomAllocator) ValidateCreateRoom(ctx context.Context, roomName livekit.RoomName) error {
// when auto create is disabled, we'll check to ensure it's already created
if !r.config.Room.AutoCreate {
_, _, err := r.roomStore.LoadRoom(ctx, roomName, false)
if err != nil {
return err
}
}
return nil
}
func applyDefaultRoomConfig(room *livekit.Room, conf *config.RoomConfig) {
room.EmptyTimeout = conf.EmptyTimeout
room.MaxParticipants = conf.MaxParticipants