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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user