Stream data sender now reacts to connection delay. It will buffer requests when the delay is high.
This commit is contained in:
15
ui/socket.js
15
ui/socket.js
@@ -22,6 +22,9 @@ import * as crypt from "./crypto.js";
|
|||||||
|
|
||||||
export const ECHO_FAILED = streams.ECHO_FAILED;
|
export const ECHO_FAILED = streams.ECHO_FAILED;
|
||||||
|
|
||||||
|
const maxSenderDelay = 200;
|
||||||
|
const minSenderDelay = 30;
|
||||||
|
|
||||||
class Dial {
|
class Dial {
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
@@ -190,7 +193,7 @@ class Dial {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
4096 - 64, // Server has a 4096 bytes receive buffer, can be no greater,
|
4096 - 64, // Server has a 4096 bytes receive buffer, can be no greater,
|
||||||
30, // 30ms input delay
|
minSenderDelay, // 30ms input delay
|
||||||
10 // max 10 buffered requests
|
10 // max 10 buffered requests
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -331,6 +334,16 @@ export class Socket {
|
|||||||
let streamHandler = new streams.Streams(conn.reader, conn.sender, {
|
let streamHandler = new streams.Streams(conn.reader, conn.sender, {
|
||||||
echoInterval: self.echoInterval,
|
echoInterval: self.echoInterval,
|
||||||
echoUpdater(delay) {
|
echoUpdater(delay) {
|
||||||
|
const sendDelay = delay / 2;
|
||||||
|
|
||||||
|
if (sendDelay > maxSenderDelay) {
|
||||||
|
conn.sender.setDelay(maxSenderDelay);
|
||||||
|
} else if (sendDelay < minSenderDelay) {
|
||||||
|
conn.sender.setDelay(minSenderDelay);
|
||||||
|
} else {
|
||||||
|
conn.sender.setDelay(sendDelay);
|
||||||
|
}
|
||||||
|
|
||||||
return callbacks.echo(delay);
|
return callbacks.echo(delay);
|
||||||
},
|
},
|
||||||
cleared(e) {
|
cleared(e) {
|
||||||
|
|||||||
@@ -41,6 +41,16 @@ export class Sender {
|
|||||||
this.bufferReq = 0;
|
this.bufferReq = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the send delay of current sender
|
||||||
|
*
|
||||||
|
* @param {integer} newDelay the new delay
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
setDelay(newDelay) {
|
||||||
|
this.bufferFlushDelay = newDelay;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends data to the this.sender
|
* Sends data to the this.sender
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user