From 9aff9af6906271014c45d02c9b5d79337eaae625 Mon Sep 17 00:00:00 2001 From: David Colburn Date: Wed, 24 Nov 2021 18:43:26 -0800 Subject: [PATCH] back to MessageRouter interface --- pkg/service/rtcservice.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/service/rtcservice.go b/pkg/service/rtcservice.go index a322231e0..5aa74819d 100644 --- a/pkg/service/rtcservice.go +++ b/pkg/service/rtcservice.go @@ -21,7 +21,7 @@ import ( ) type RTCService struct { - router routing.Router + router routing.MessageRouter roomAllocator RoomAllocator upgrader websocket.Upgrader currentNode routing.LocalNode @@ -29,7 +29,7 @@ type RTCService struct { limits config.LimitConfig } -func NewRTCService(conf *config.Config, ra RoomAllocator, router routing.Router, currentNode routing.LocalNode) *RTCService { +func NewRTCService(conf *config.Config, ra RoomAllocator, router routing.MessageRouter, currentNode routing.LocalNode) *RTCService { s := &RTCService{ router: router, roomAllocator: ra, @@ -77,9 +77,11 @@ func (s *RTCService) validate(r *http.Request) (string, routing.ParticipantInit, roomName = onlyName } - if foundNode, err := s.router.GetNodeForRoom(r.Context(), roomName); err == nil { - if selector.LimitsReached(s.limits, foundNode.Stats) { - return "", routing.ParticipantInit{}, http.StatusServiceUnavailable, rtc.ErrLimitExceeded + if router, ok := s.router.(routing.Router); ok { + if foundNode, err := router.GetNodeForRoom(r.Context(), roomName); err == nil { + if selector.LimitsReached(s.limits, foundNode.Stats) { + return "", routing.ParticipantInit{}, http.StatusServiceUnavailable, rtc.ErrLimitExceeded + } } }