第41篇白板同步延迟问题(三)

关键词:白板同步延迟问题

一、把同步时间1000改成500,看看有没有助于减少延迟

1.1 相关代码

connection.onmessage = appendDIV;

       connection.filesContainer = document.getElementById('file-container');

 

       connection.onopen = function() {

           document.getElementById('share-file').disabled = false;

           document.getElementById('input-text-chat').disabled = false;

           document.getElementById('btn-leave-room').disabled = false;

            //alert(connection.getAllParticipants());

           // alert(document.getElementById('room-id').value);

           //

           document.querySelector('h1').innerHTML = 'You are connected with: ' +connection.getAllParticipants().join(', ');

 

       // mfu start

       var infoBar = document.getElementById('hide-on-datachannel-opened');

           // infoBar.innerHTML = '<b>' + event.userid + '</b> is readyto collaborate with you.';

           infoBar.innerHTML = '<b>' + connection.getAllParticipants().join(',')  + '</b> is ready to collaboratewith you.';

 

           if(designer.pointsLength <= 0) {

                // make sure that remote usergets all drawings synced.

               setTimeout(function() {

                   connection.send('plz-sync-points');

                }, 1000);

           }

 

           numberOfConnectedUsers.innerHTML =connection.getAllParticipants().length;

       // mfu end

       };

注:把上述红字代码修改如下:

               setTimeout(function() {

                   connection.send('plz-sync-points');

                }, 500);

1.2 看下线条是怎么同步的

  a) 连接函数如下:

       connection.onopen = function() {

           document.getElementById('share-file').disabled = false;

           document.getElementById('input-text-chat').disabled = false;

           document.getElementById('btn-leave-room').disabled = false;

   

           // alert(document.getElementById('room-id').value);

           //

           document.querySelector('h1').innerHTML = 'You are connected with: ' +connection.getAllParticipants().join(', ');

 

       // mfu start

       varinfoBar = document.getElementById('hide-on-datachannel-opened');

           // infoBar.innerHTML = '<b>' + event.userid + '</b> is readyto collaborate with you.';

           infoBar.innerHTML = '<b>' +connection.getAllParticipants().join(', ') + '</b> is ready to collaborate with you.';

 

           if(designer.pointsLength <= 0) {

                // make sure that remote usergets all drawings synced.

                setTimeout(function() {

                   connection.send('plz-sync-points');

                }, 1000);

           }

 

           numberOfConnectedUsers.innerHTML = connection.getAllParticipants().length;

       // mfu end

       };

注:老师端往学生端传数据是两个两个传的,学生端往老师端传数据是一个一下传的。并且数值是连续的。

运行截图如下:

老师往学生传数据如下:

学生往老师传数据如下:

二、我发现了一个规律

   就是说一端插网线,另一端用wifi,异网传输秒传;

   两端都是wifi,白板传输有延迟,语音流畅;

2016年12月24日星期六

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值