关键词:白板同步延迟问题
一、把同步时间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日星期六