Rev 969 | Rev 974 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 969 | Rev 971 | ||
|---|---|---|---|
| Line 20... | Line 20... | ||
| 20 | } |
20 | } |
| 21 | 21 | ||
| 22 | CanService.prototype.onlineHandler = function() |
22 | CanService.prototype.onlineHandler = function() |
| 23 | { |
23 | { |
| 24 | log(this.myName + ":" + this.myId + "> Service went online\n"); |
24 | log(this.myName + ":" + this.myId + "> Service went online\n"); |
| - | 25 | var date = new Date(); |
|
| 25 | this.myHeartbeatTime = |
26 | this.myHeartbeatTime = date.getTimestamp(); |
| 26 | this.myIsOnline = true; |
27 | this.myIsOnline = true; |
| 27 | this.callEvent("online", null); |
28 | this.callEvent("online", null); |
| 28 | } |
29 | } |
| 29 | 30 | ||
| 30 | CanService.prototype.heartbeatHandler = function() |
31 | CanService.prototype.heartbeatHandler = function() |
| 31 | { |
32 | { |
| - | 33 | var date = new Date(); |
|
| 32 | this.myHeartbeatTime = |
34 | this.myHeartbeatTime = date.getTimestamp(); |
| 33 | this.myIsOnline = true; |
35 | this.myIsOnline = true; |
| 34 | this.callEvent("heartbeat", null); |
36 | this.callEvent("heartbeat", null); |
| 35 | } |
37 | } |
| 36 | 38 | ||
| 37 | CanService.prototype.checkOffline = function() |
39 | CanService.prototype.checkOffline = function() |
| 38 | { |
40 | { |
| 39 | if (this.myIsOnline) |
41 | if (this.myIsOnline) |
| 40 | { |
42 | { |
| - | 43 | var date = new Date(); |
|
| 41 | if (this.myHeartbeatTime + 10 < |
44 | if (this.myHeartbeatTime + 10 < date.getTimestamp()) |
| 42 | { |
45 | { |
| 43 | log(this.myName + ":" + this.myId + "> Service went offline\n"); |
46 | log(this.myName + ":" + this.myId + "> Service went offline\n"); |
| 44 | this.myIsOnline = false; |
47 | this.myIsOnline = false; |
| 45 | this.callEvent("offline", null); |
48 | this.callEvent("offline", null); |
| 46 | } |
49 | } |