SendData API & publishData permission (#88)

* SendData Server API

* SendData Server-API adjustments based on suggestions

* Update proto version

* enforce publishData permission

* go mod tidy

* fix go.mod

* go mod tidy

Co-authored-by: ChesterMing <89124853+ChesterMing@users.noreply.github.com>
This commit is contained in:
David Zhao
2021-08-19 18:11:48 -07:00
committed by GitHub
co-authored by ChesterMing
parent 2ab37d8fcc
commit bcf6e15e07
15 changed files with 163 additions and 59 deletions
+15 -1
View File
@@ -352,6 +352,16 @@ func (r *Room) OnParticipantChanged(f func(participant types.Participant)) {
r.onParticipantChanged = f
}
func (r *Room) SendDataPacket(up *livekit.UserPacket, kind livekit.DataPacket_Kind) {
dp := &livekit.DataPacket{
Kind: kind,
Value: &livekit.DataPacket_User{
User: up,
},
}
r.onDataPacket(nil, dp)
}
// checks if participant should be autosubscribed to new tracks, assumes lock is already acquired
func (r *Room) autoSubscribe(participant types.Participant) bool {
if !participant.CanSubscribe() {
@@ -422,13 +432,17 @@ func (r *Room) onParticipantMetadataUpdate(p types.Participant) {
}
func (r *Room) onDataPacket(source types.Participant, dp *livekit.DataPacket) {
// don't forward if source isn't allowed to publish data
if source != nil && !source.CanPublishData() {
return
}
dest := dp.GetUser().GetDestinationSids()
for _, op := range r.GetParticipants() {
if op.State() != livekit.ParticipantInfo_ACTIVE {
continue
}
if op.ID() == source.ID() {
if source != nil && op.ID() == source.ID() {
continue
}
if len(dest) > 0 {