MCPcopy
hub / github.com/livekit/livekit / RemoveParticipant

Method RemoveParticipant

pkg/rtc/room.go:1396–1489  ·  view source on GitHub ↗
(
	identity livekit.ParticipantIdentity,
	pID livekit.ParticipantID,
	reason types.ParticipantCloseReason,
)

Source from the content-addressed store, hash-verified

1394}
1395
1396func (r *Room) RemoveParticipant(
1397 identity livekit.ParticipantIdentity,
1398 pID livekit.ParticipantID,
1399 reason types.ParticipantCloseReason,
1400) {
1401 r.lock.Lock()
1402 p, ok := r.participants[identity]
1403 if !ok {
1404 r.lock.Unlock()
1405 return
1406 }
1407
1408 if pID != "" && p.ID() != pID {
1409 // participant session has been replaced
1410 r.lock.Unlock()
1411 return
1412 }
1413
1414 agentJob := r.agentParticpants[identity]
1415
1416 delete(r.participants, identity)
1417 delete(r.participantOpts, identity)
1418 delete(r.participantRequestSources, identity)
1419 delete(r.hasPublished, identity)
1420 delete(r.agentParticpants, identity)
1421 if !p.Hidden() {
1422 r.protoRoom.NumParticipants--
1423 }
1424
1425 immediateChange := false
1426 if p.IsRecorder() {
1427 activeRecording := false
1428 for _, op := range r.participants {
1429 if op.IsRecorder() {
1430 activeRecording = true
1431 break
1432 }
1433 }
1434
1435 if r.protoRoom.ActiveRecording != activeRecording {
1436 r.protoRoom.ActiveRecording = activeRecording
1437 immediateChange = true
1438 }
1439 }
1440 r.lock.Unlock()
1441 r.protoProxy.MarkDirty(immediateChange)
1442
1443 if !p.HasConnected() {
1444 fields := append(
1445 connectionDetailsFields(p.GetICEConnectionInfo()),
1446 "reason", reason.String(),
1447 "clientInfo", logger.Proto(sutils.ClientInfoWithoutAddress(p.GetClientInfo())),
1448 )
1449 p.GetLogger().Infow("removing participant without connection", fields...)
1450 }
1451
1452 // send broadcast only if it's not already closed
1453 sendUpdates := !p.IsDisconnected()

Callers 4

JoinMethod · 0.95
DeleteAgentDispatchMethod · 0.95
onStateChangeMethod · 0.95
onLeaveMethod · 0.95

Calls 15

connectionDetailsFieldsFunction · 0.85
RemoveDataTrackMethod · 0.80
participantLeftMethod · 0.80
StoreMethod · 0.80
IDMethod · 0.65
HiddenMethod · 0.65
IsRecorderMethod · 0.65
HasConnectedMethod · 0.65
GetICEConnectionInfoMethod · 0.65
GetClientInfoMethod · 0.65
GetLoggerMethod · 0.65

Tested by

no test coverage detected