Skip to content
Snippets Groups Projects
Commit 511616a9 authored by deuce's avatar deuce
Browse files

Add session timeout support.

parent a6d7c1f9
Branches
Tags
No related merge requests found
...@@ -369,6 +369,7 @@ BinkP.prototype.session = function() ...@@ -369,6 +369,7 @@ BinkP.prototype.session = function()
var ver; var ver;
var args; var args;
var size; var size;
var last = Date.now();
// Session set up, we're good to go! // Session set up, we're good to go!
outer: outer:
...@@ -377,6 +378,7 @@ BinkP.prototype.session = function() ...@@ -377,6 +378,7 @@ BinkP.prototype.session = function()
// skipping files. // skipping files.
pkt = this.recvFrame(this.senteob ? this.timeout : 0); pkt = this.recvFrame(this.senteob ? this.timeout : 0);
if (pkt !== undefined && pkt !== this.partialFrame && pkt !== null) { if (pkt !== undefined && pkt !== this.partialFrame && pkt !== null) {
last = Date.now();
if (pkt.is_cmd) { if (pkt.is_cmd) {
cmd_switch: cmd_switch:
switch(pkt.command) { switch(pkt.command) {
...@@ -537,12 +539,16 @@ BinkP.prototype.session = function() ...@@ -537,12 +539,16 @@ BinkP.prototype.session = function()
} }
} }
if (this.sending !== undefined) { if (this.sending !== undefined) {
this.sendData(this.sending.read(32767)); if(this.sendData(this.sending.read(32767)))
last = Date.now();
if (this.eof || this.sending.position >= this.sending.length) { if (this.eof || this.sending.position >= this.sending.length) {
this.sending.close(); this.sending.close();
this.sending = undefined; this.sending = undefined;
} }
} }
if ((last + this.timeout)*1000 < Date.now())
this.sendCmd(this.command.M_ERR, "Timeout exceeded!");
} }
this.close(); this.close();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment