MCPcopy
hub / github.com/livekit/livekit / Add

Method Add

pkg/rtc/migrationdatacache.go:36–55  ·  view source on GitHub ↗

Add adds a message to the cache if there is a gap between the last sequence number and cached messages then return the cache State: - MigrationDataCacheStateWaiting: waiting for the next packet (lastSeq + 1) of last sequence from old node - MigrationDataCacheStateTimeout: the next packet is not rece

(pkt *livekit.DataPacket)

Source from the content-addressed store, hash-verified

34// continue to process the reliable messages, subscribers will see the gap after the publisher migration
35// - MigrationDataCacheStateDone: the next packet is received, participant can continue to process the reliable messages
36func (c *MigrationDataCache) Add(pkt *livekit.DataPacket) MigrationDataCacheState {
37 if c.state == MigrationDataCacheStateDone || c.state == MigrationDataCacheStateTimeout {
38 return c.state
39 }
40
41 if pkt.Sequence <= c.lastSeq {
42 return c.state
43 }
44
45 if pkt.Sequence == c.lastSeq+1 {
46 c.state = MigrationDataCacheStateDone
47 return c.state
48 }
49
50 c.pkts = append(c.pkts, pkt)
51 if time.Now().After(c.expiredAt) {
52 c.state = MigrationDataCacheStateTimeout
53 }
54 return c.state
55}
56
57func (c *MigrationDataCache) Get() []*livekit.DataPacket {
58 return c.pkts

Callers 15

SendJoinResponseMethod · 0.45
SendParticipantUpdateMethod · 0.45
AddBytesMethod · 0.45
untilTransportsConnectedFunction · 0.45
newPeerConnectionFunction · 0.45
NegotiateMethod · 0.45
SetPreviousSdpMethod · 0.45
onSimulateScenarioMethod · 0.45
onDataMessageMethod · 0.45
WaitUntilSubscribedMethod · 0.45
recordAttemptMethod · 0.45

Calls

no outgoing calls