MCPcopy
hub / github.com/livekit/livekit / serve

Method serve

pkg/service/rtcservice.go:294–629  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, needsJoinRequest bool)

Source from the content-addressed store, hash-verified

292}
293
294func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequest bool) {
295 // reject non websocket requests
296 if !websocket.IsWebSocketUpgrade(r) {
297 w.WriteHeader(404)
298 return
299 }
300
301 startedAt := time.Now()
302 var (
303 roomName livekit.RoomName
304 roomID livekit.RoomID
305 participantIdentity livekit.ParticipantIdentity
306 pID livekit.ParticipantID
307 joinDuration time.Duration
308 loggerResolved bool
309
310 pi routing.ParticipantInit
311 code int
312 err error
313 )
314
315 pLogger, loggerResolver := utils.GetLogger(r.Context()).WithDeferredValues()
316
317 getLoggerFields := func() []any {
318 return []any{
319 "room", roomName,
320 "roomID", roomID,
321 "participant", participantIdentity,
322 "participantID", pID,
323 "joinDuration", joinDuration,
324 }
325 }
326
327 resolveLogger := func(force bool) {
328 if loggerResolved {
329 return
330 }
331
332 if force {
333 if roomName == "" {
334 roomName = "unresolved"
335 }
336 if roomID == "" {
337 roomID = "unresolved"
338 }
339 if participantIdentity == "" {
340 participantIdentity = "unresolved"
341 }
342 if pID == "" {
343 pID = "unresolved"
344 }
345 if joinDuration == 0 {
346 joinDuration = time.Since(startedAt)
347 }
348 }
349
350 if roomName != "" && roomID != "" && participantIdentity != "" && pID != "" {
351 loggerResolved = true

Callers 2

v0Method · 0.95
v1Method · 0.95

Calls 15

validateInternalMethod · 0.95
startConnectionMethod · 0.95
ResolveRoomMethod · 0.95
ResolveParticipantMethod · 0.95
WriteResponseMethod · 0.95
ResetMethod · 0.95
ReadRequestMethod · 0.95
GetLoggerFunction · 0.92
ContextWithAttemptFunction · 0.92
NewBytesSignalStatsFunction · 0.92

Tested by

no test coverage detected