Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 使用flatter_webrtc包进行二进制数据传输_Flutter_Webrtc_Rtcdatachannel - Fatal编程技术网

Flutter 使用flatter_webrtc包进行二进制数据传输

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

我可以使用Flatter webrtc发送字符串消息,但当我尝试发送二进制文件时,它会显示NetworkError:未能在“RTCDataChannel”上执行“发送”:无法发送数据。我尝试了小于2kb的文件

  _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
中找到实现