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(
participant: senderParticipant,
data: dataPacketEvent.packet.payload,
topic: dataPacketEvent.packet.topic,
);
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.
final RemoteParticipant? participant;
final List<int> data;
final String? topic;
const DataReceivedEvent({
required this.participant,
required this.data,
required this.topic,
});
@override
+3
View File
@@ -256,10 +256,12 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
/// Publish a new data payload to 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(
List<int> data, {
Reliability reliability = Reliability.reliable,
List<String>? destinationSids,
String? topic,
}) async {
final packet = lk_models.DataPacket(
kind: reliability.toPBType(),
@@ -267,6 +269,7 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
payload: data,
participantSid: sid,
destinationSids: destinationSids,
topic: topic,
),
);