feat: topic for data-channel. (#260)

This commit is contained in:
CloudWebRTC
2023-03-27 09:19:42 +08:00
committed by GitHub
parent 59ee3105fb
commit 68d611a448
3 changed files with 6 additions and 0 deletions
+1
View File
@@ -550,6 +550,7 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
final event = DataReceivedEvent( final event = DataReceivedEvent(
participant: senderParticipant, participant: senderParticipant,
data: dataPacketEvent.packet.payload, data: dataPacketEvent.packet.payload,
topic: dataPacketEvent.packet.topic,
); );
senderParticipant?.events.emit(event); senderParticipant?.events.emit(event);
+2
View File
@@ -347,9 +347,11 @@ class DataReceivedEvent with RoomEvent, ParticipantEvent {
/// Sender of the data. This may be null if data is sent from Server API. /// Sender of the data. This may be null if data is sent from Server API.
final RemoteParticipant? participant; final RemoteParticipant? participant;
final List<int> data; final List<int> data;
final String? topic;
const DataReceivedEvent({ const DataReceivedEvent({
required this.participant, required this.participant,
required this.data, required this.data,
required this.topic,
}); });
@override @override
+3
View File
@@ -256,10 +256,12 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
/// Publish a new data payload to the room. /// Publish a new data payload to the room.
/// @param destinationSids When empty, data will be forwarded to each participant in the room. /// @param destinationSids When empty, data will be forwarded to each participant in the room.
/// @param topic, the topic under which the message gets published.
Future<void> publishData( Future<void> publishData(
List<int> data, { List<int> data, {
Reliability reliability = Reliability.reliable, Reliability reliability = Reliability.reliable,
List<String>? destinationSids, List<String>? destinationSids,
String? topic,
}) async { }) async {
final packet = lk_models.DataPacket( final packet = lk_models.DataPacket(
kind: reliability.toPBType(), kind: reliability.toPBType(),
@@ -267,6 +269,7 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
payload: data, payload: data,
participantSid: sid, participantSid: sid,
destinationSids: destinationSids, destinationSids: destinationSids,
topic: topic,
), ),
); );