javascript - WebRTC RTCDataChannel readyState 什么时候打开?
问题描述
我在 WebRTC 中创建了一个简单的原型,它使用 Google 提供的测试 STUN 服务器:
var servers = [
"stun:stun.l.google.com:19302",
...
];
我运行了两个独立的应用程序(没有本地服务器 - 即 NodeJS)。
我只是通过网络浏览器直接打开了文件。
它成功地创建了一个RTCPeerConnection
和RTCDataChannel
对象。
但是,onopen
处理程序RTCDataChannel
从未被触发。数据通道始终处于“连接”状态
。readyState
示例代码:
window.localConnection = localConnection =
new RTCPeerConnection(configuration); // configuration.iceServer
localChannel = localConnection.createDataChannel('data');
localChannel.onopen = function () { // never triggered
var readyState = localChannel.readyState;
console.log('Local channel state is: ' + readyState);
}
问题:
1. 我需要一个服务器(如 NodeJS)来readyState
设置“打开”吗?
2. 什么时候readyState
转换到“开放”状态?
解决方案
推荐阅读
- node.js - 通过 AWS Cloudfront 从 AWS Elasticbeanstalk 部署 apollo-server 不兼容
- android - 如何在 android 上使用 smack 4.3.5 检索用户的真实姓名?
- c++ - 无法在 arduinoIDE 中包含数组
- laravel - 如何在 Laravel 中使用 join 查找 DB 语句中的关系缺失
- virtuoso - 删除大图后如何缩小 virtuoso.db 文件大小?
- react-datepicker - 在 react-datepicker 中的日历和月份选择器之间切换?
- python - 遗传算法没有改进
- windows - Powershell、GCI 出问题了?非空文件夹大小返回 0
- arrays - “维度大小不相等,目标数组不灵活。”
- ms-access - 重音字符间歇性地从 Access 中正确复制到 SAP