Flutter 使用flatter_webrtc包进行二进制数据传输
我可以使用Flatter webrtc发送字符串消息,但当我尝试发送二进制文件时,它会显示NetworkError:未能在“RTCDataChannel”上执行“发送”:无法发送数据。我尝试了小于2kb的文件Flutter 使用flatter_webrtc包进行二进制数据传输,flutter,webrtc,rtcdatachannel,Flutter,Webrtc,Rtcdatachannel,我可以使用Flatter webrtc发送字符串消息,但当我尝试发送二进制文件时,它会显示NetworkError:未能在“RTCDataChannel”上执行“发送”:无法发送数据。我尝试了小于2kb的文件 _sendFile(){ if(DC==null){ print("DC IS NULl"); } else{ if(_file!=null){ DC.send(RTCDataChannelMessag
_sendFile(){
if(DC==null){
print("DC IS NULl");
}
else{
if(_file!=null){
DC.send(RTCDataChannelMessage.fromBinary(_file.files.single.bytes));
}else{
print("File is null");
}
}
}
_sendMessage(){
if(DC==null){
print("DC IS NULl");
}
print(DC.state);
try{
DC.send(RTCDataChannelMessage(messageController.text));
} catch(e){
print(e);
}
}
//处理消息
DC.onMessage=(e){
print("on message");
if(!e.isBinary){
print(e.text);
}else{
print(e.binary.length);
}
};
您可以在此存储库中的
数据通道\u sample.dart
中找到实现