正在显示
1 个修改的文件
包含
8 行增加
和
5 行删除
| @@ -151,8 +151,9 @@ internal constructor( | @@ -151,8 +151,9 @@ internal constructor( | ||
| 151 | * | 151 | * |
| 152 | * @param data payload to send | 152 | * @param data payload to send |
| 153 | * @param reliability for delivery guarantee, use RELIABLE. for fastest delivery without guarantee, use LOSSY | 153 | * @param reliability for delivery guarantee, use RELIABLE. for fastest delivery without guarantee, use LOSSY |
| 154 | + * @param destination list of participant SIDs to deliver the payload, null to deliver to everyone | ||
| 154 | */ | 155 | */ |
| 155 | - fun publishData(data: ByteArray, reliability: DataPublishReliability) { | 156 | + fun publishData(data: ByteArray, reliability: DataPublishReliability, destination: List<String>?) { |
| 156 | if (data.size > RTCEngine.MAX_DATA_PACKET_SIZE) { | 157 | if (data.size > RTCEngine.MAX_DATA_PACKET_SIZE) { |
| 157 | throw IllegalArgumentException("cannot publish data larger than " + RTCEngine.MAX_DATA_PACKET_SIZE) | 158 | throw IllegalArgumentException("cannot publish data larger than " + RTCEngine.MAX_DATA_PACKET_SIZE) |
| 158 | } | 159 | } |
| @@ -166,12 +167,14 @@ internal constructor( | @@ -166,12 +167,14 @@ internal constructor( | ||
| 166 | DataPublishReliability.LOSSY -> engine.lossyDataChannel | 167 | DataPublishReliability.LOSSY -> engine.lossyDataChannel |
| 167 | } ?: throw TrackException.PublishException("data channel not established") | 168 | } ?: throw TrackException.PublishException("data channel not established") |
| 168 | 169 | ||
| 169 | - val userPacket = LivekitRtc.UserPacket.newBuilder(). | 170 | + val packetBuilder = LivekitRtc.UserPacket.newBuilder(). |
| 170 | setPayload(ByteString.copyFrom(data)). | 171 | setPayload(ByteString.copyFrom(data)). |
| 171 | - setParticipantSid(sid). | ||
| 172 | - build() | 172 | + setParticipantSid(sid) |
| 173 | + if (destination != null) { | ||
| 174 | + packetBuilder.addAllDestinationSids(destination) | ||
| 175 | + } | ||
| 173 | val dataPacket = LivekitRtc.DataPacket.newBuilder(). | 176 | val dataPacket = LivekitRtc.DataPacket.newBuilder(). |
| 174 | - setUser(userPacket). | 177 | + setUser(packetBuilder). |
| 175 | setKind(kind). | 178 | setKind(kind). |
| 176 | build() | 179 | build() |
| 177 | val buf = DataChannel.Buffer( | 180 | val buf = DataChannel.Buffer( |
-
请 注册 或 登录 后发表评论