Add subchannels in DataChannels (dataProducer.send() method)
ibc opened this issue · comments
Mechanism to specify which DataConsumers
should receive a message sent via dataProducer.send()
.
const dataConsumer = await transport.consumeData({
[...],
subchannels: [ 0, 2, 5 ]
});
const subchannels = dataConsumer.subchannels;
// => [ 0, 2, 5 ] (cloned array)
await dataConsumer.setSubchannels([ 1, 2, 5 ]);
// => Set(4) { 0, 2, 5, 4 }
const subchannels = dataConsumer.subchannels;
// => [ 1, 2, 5 ] (cloned array)
await dataConsumer.setSubchannels([]);
// => [] (cloned array)
// Send a message to all DataConsumers regardless their subchannels.
dataPoducer.send(
message,
/* ppid */
undefined,
/* subchannels */
undefined,
/* requiredSubchannel */
undefined
);
// Send a message only to DataConsumers in subchannels 1 or 2.
dataPoducer.send(
message,
/* ppid */
undefined,
/* subchannels */
[ 1, 2 ],
/* requiredSubchannel */
undefined
);
// Send a message only to DataConsumers in subchannels 1 or 2 but just
// if also in subchannel 0.
dataPoducer.send(
message,
/* ppid */
undefined,
/* subchannels */
[ 1, 2 ],
/* requiredSubchannel */
0
);
This is done long time ago.