feat: topic for data-channel. (#260)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user