Mercurial > hg > rlgwebd
comparison rlgterm.js @ 35:f15efa4818b4
rglterm.js: reduce the server polling.
For roguelike games, most output will directly result from and follow
immediately after input from the user. In other situations, data
should not be expected.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Tue, 05 Jun 2012 22:33:41 -0700 |
parents | 83f9a799a374 |
children | b06a14876645 |
comparison
equal
deleted
inserted
replaced
34:57f4b36ef06b | 35:f15efa4818b4 |
---|---|
13 set: function (ms) { | 13 set: function (ms) { |
14 this.clear(); | 14 this.clear(); |
15 this.timerID = window.setTimeout(getData, ms); | 15 this.timerID = window.setTimeout(getData, ms); |
16 }, | 16 }, |
17 gotdata: function () { | 17 gotdata: function () { |
18 this.set(100); | 18 this.set(1000); |
19 this.state = 0; | 19 this.state = 1; |
20 }, | 20 }, |
21 gotnothing: function () { | 21 gotnothing: function () { |
22 if (this.state == 0) { | 22 if (this.state == 0) { |
23 this.set(100); | 23 this.set(1000); |
24 this.state = 1; | 24 this.state = 1; |
25 } | 25 } |
26 else if (this.state == 1) { | 26 else { |
27 this.set(300); | 27 this.set(4000); |
28 this.state = 2; | 28 this.state = 2; |
29 } | 29 } |
30 else if (this.state == 2) { | 30 }, |
31 posted: function (wasdata) { | |
32 if (wasdata) { | |
31 this.set(1000); | 33 this.set(1000); |
32 this.state = 3; | 34 this.state = 1; |
33 } | 35 } |
34 else { | 36 else { |
35 this.set(5000); | 37 this.set(200); |
36 this.state = 3; | 38 this.state = 0; |
37 } | 39 } |
38 }, | |
39 posted: function () { | |
40 this.set(100); | |
41 this.state = 0; | |
42 } | 40 } |
43 }; | 41 }; |
44 | 42 |
45 function writeData(hexstr) { | 43 function writeData(hexstr) { |
46 var codenum; | 44 var codenum; |