Open faizatflutter opened 2 years ago
I forgot to tell use jsonEncode/Decode for conversion of your message to string. I created function below for my project.I used webrct data channel.
final Completer completer = Completer();
int start = (currentChunkId - 1) * Config.webrtcDataChannelChunkSize;
int end = currentChunkId * Config.webrtcDataChannelChunkSize;
if (end > mainModel.offerModel.fileSize) {
end = mainModel.offerModel.fileSize;
}
List<int> data = [];
Stream<List<int>> dataStream = mainModel.file.openRead(start, end);
dataStream.listen((List<int> event) {
data.addAll(event);
}, onDone: () async {
DCTransferModel model = DCTransferModel(
fileId: mainModel.offerModel.fileId,
chunkId: currentChunkId,
//data: data,
data: base64Encode(gzip.encode(data)),
);
await _dataChannel!.send(RTCDataChannelMessage(model.toJson));
mainModel.progress.value =
currentChunkId / mainModel.offerModel.totalChunks;
completer.complete();
});
return completer.future;
}```
I forgot to tell use jsonEncode/Decode for conversion of your message to string. I created function below for my project.I used webrct data channel.
@abhay-s-rawat Can you provide a more detailed example?
Did anyone get this working?
Actually you can send file. For large files you have to read them which will consume more memory, I guess the maxed allowed packet size is 1mb so break your file into chunks and send which will save ram also.