type definition of room name (#311)

* WIP commit

* update protocol

* Fixing a test and catching one place where casting was missed

* Fix one more spot which need conversion from livekit.RoomName -> string

* do not covert list
This commit is contained in:
Raja Subramanian
2022-01-02 16:49:16 +05:30
committed by GitHub
parent 66a1ffe414
commit 3a9009ae12
21 changed files with 208 additions and 208 deletions
+3 -3
View File
@@ -57,7 +57,7 @@ func (s *RTCService) Validate(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte("success"))
}
func (s *RTCService) validate(r *http.Request) (string, routing.ParticipantInit, int, error) {
func (s *RTCService) validate(r *http.Request) (livekit.RoomName, routing.ParticipantInit, int, error) {
claims := GetGrants(r.Context())
// require a claim
if claims == nil || claims.Video == nil {
@@ -69,7 +69,7 @@ func (s *RTCService) validate(r *http.Request) (string, routing.ParticipantInit,
return "", routing.ParticipantInit{}, http.StatusUnauthorized, err
}
roomName := r.FormValue("room")
roomName := livekit.RoomName(r.FormValue("room"))
reconnectParam := r.FormValue("reconnect")
autoSubParam := r.FormValue("auto_subscribe")
publishParam := r.FormValue("publish")
@@ -130,7 +130,7 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
// create room if it doesn't exist, also assigns an RTC node for the room
rm, err := s.roomAllocator.CreateRoom(r.Context(), &livekit.CreateRoomRequest{Name: roomName})
rm, err := s.roomAllocator.CreateRoom(r.Context(), &livekit.CreateRoomRequest{Name: string(roomName)})
if err != nil {
prometheus.ServiceOperationCounter.WithLabelValues("signal_ws", "error", "create_room").Add(1)
handleError(w, http.StatusInternalServerError, err.Error())