Add the ability to send data to specific participants (#34)

* UserPacket destination filter

* Updated protocol to v0.5.2

* Added DataChannel tests
This commit is contained in:
Théo Monnom
2021-06-09 12:14:14 -07:00
committed by GitHub
parent bbf7f83784
commit 321ebab99b
4 changed files with 78 additions and 1 deletions
+14
View File
@@ -391,6 +391,8 @@ func (r *Room) onParticipantMetadataUpdate(p types.Participant) {
}
func (r *Room) onDataPacket(source types.Participant, dp *livekit.DataPacket) {
dest := dp.GetUser().GetDestinationSids()
for _, op := range r.GetParticipants() {
if op.State() != livekit.ParticipantInfo_ACTIVE {
continue
@@ -398,6 +400,18 @@ func (r *Room) onDataPacket(source types.Participant, dp *livekit.DataPacket) {
if op.ID() == source.ID() {
continue
}
if len(dest) > 0 {
found := false
for _, dSid := range dest {
if op.ID() == dSid {
found = true
break
}
}
if !found {
continue
}
}
_ = op.SendDataPacket(dp)
}
}