(w http.ResponseWriter, r *http.Request, needsJoinRequest bool)
| 292 | } |
| 293 | |
| 294 | func (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 |
no test coverage detected