测试coturn服务器是否可用(Webrtc)
来源:互联网 发布:江歌案始末知乎 编辑:程序博客网 时间:2024/05/22 13:28
function checkTURNServer(turnConfig, timeout){ return new Promise(function(resolve, reject){ setTimeout(function(){ if(promiseResolved) return; resolve(false); promiseResolved = true; }, timeout || 5000); var promiseResolved = false , myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection //compatibility for firefox and chrome , pc = new myPeerConnection({iceServers:[turnConfig]}) , noop = function(){}; pc.createDataChannel(""); //create a bogus data channel pc.createOffer(function(sdp){ if(sdp.sdp.indexOf('typ relay') > -1){ // sometimes sdp contains the ice candidates... promiseResolved = true; resolve(true); } pc.setLocalDescription(sdp, noop, noop); }, noop); // create offer and set local description pc.onicecandidate = function(ice){ //listen for candidate events if(promiseResolved || !ice || !ice.candidate || !ice.candidate.candidate || !(ice.candidate.candidate.indexOf('typ relay')>-1)) return; promiseResolved = true; resolve(true); }; }); } checkTURNServer({ url: 'turn:*.*.*.*', username: '×××××××', credential: '××××××××××', }).then(function(bool){ console.log('is my TURN server active? ', bool? 'yes':'no'); }).catch(console.error.bind(console));
0 0
- 测试coturn服务器是否可用(Webrtc)
- Webrtc服务器搭建 (coturn)
- webrtc coturn服务器搭建
- 测试链接服务器是否可用
- webRTC+coturn穿透服务器的安装与搭建
- WEBRTC RELAY---COTURN
- p2p webrtc服务器搭建系列1: 房间,信令,coturn打洞服务器
- COTURN服务器使用
- coturn(turn)服务器搭建
- 配置coturn服务器
- 简单测试dns列表中的dns服务器是否可用
- 测试JSON是否可用
- 测试Atlas是否可用
- coturn(turn/stun)服务器搭建
- webrtc测试服务器编译和搭建
- Ubuntu Server 14.04下配置coturn for WebRTC
- 测试服务器是否启动
- 如何控制服务器按钮是否可用
- 摊平嵌套列表-lintcode
- Hadoop之Yarn学习(一)
- 15:Trapping Rain Water
- Java代码执行顺序
- myeclipse10.5下载以及破解
- 测试coturn服务器是否可用(Webrtc)
- As导入第三方类库可能出现R文件丢失的解决方案
- Android 仿闹钟 及 通知栏的实现
- 一个基于Win32的文本编辑器源码
- 基于毕业季的规划(提纲)
- 16: Rotate Image
- 类的构造函数
- IOS的app运行时上下有黑边,非全屏
- 从 php 内核挂载钩子解密源码