Fix bug: Upload file failed due to inconsistent peer rate

修复bug:两端速率不一致导致上传文件失败

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
Jianhui Zhao
2018-03-30 00:35:01 +08:00
parent 643abc0281
commit d3f89ec353
5 changed files with 16 additions and 3 deletions
Executable → Regular
+9 -2
View File
@@ -177,8 +177,10 @@ export default {
this.upfile.percent = Math.round(this.upfile.pos / this.upfile.file.size * 100)
if (this.upfile.pos < this.upfile.file.size) {
/* Control the client read speed based on the current buffer */
if (this.ws.bufferedAmount > this.upfile.pos * 10) {
/* Control the client read speed based on the current buffer and server */
if (this.ws.bufferedAmount > this.upfile.pos * 10 || this.ratelimit) {
this.ratelimit = false;
setTimeout(() => {
this.readFile(fr);
}, 100);
@@ -334,6 +336,11 @@ export default {
this.downfile.modal = false;
this.$Message.info("Download Finish");
}
} else if (pkt.typ == rtty.RTTY_PACKET_UPFILE) {
if (pkt.code == 5) {
/* Need reduce the sending rate */
this.ratelimit = true;
}
}
});
Executable → Regular
View File
Executable → Regular
View File