diff options
Diffstat (limited to 'NET/worlds/console/StatNetRefNode.java')
| -rw-r--r-- | NET/worlds/console/StatNetRefNode.java | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/NET/worlds/console/StatNetRefNode.java b/NET/worlds/console/StatNetRefNode.java new file mode 100644 index 0000000..9ce6fe2 --- /dev/null +++ b/NET/worlds/console/StatNetRefNode.java @@ -0,0 +1,106 @@ +package NET.worlds.console; + +import NET.worlds.core.Std; +import NET.worlds.network.NetworkRoom; +import NET.worlds.network.WorldServer; +import NET.worlds.scape.Pilot; +import NET.worlds.scape.Room; +import java.awt.List; +import java.util.Vector; + +public class StatNetRefNode extends StatMan implements MainCallback { + private static StatNetRefNode _singleInstance = new StatNetRefNode(); + private int _totBytesSent; + private int _totBytesRcvd; + private int _totPacketsSent; + private int _totPacketsRcvd; + private int _lastTime; + private static final int TITLE = 0; + private static final int BLANK = 1; + private int _listCount = 0; + + public static StatNetRefNode getNode() { + return _singleInstance; + } + + private StatNetRefNode() { + StatNetNode.getNode().addChild(this); + } + + @Override + public String toString() { + return "Drone Referrers to Current Server"; + } + + public void addBytesSent(int bytesSent) { + this._totBytesSent += bytesSent; + } + + public void addBytesRcvd(int bytesRcvd) { + this._totBytesRcvd += bytesRcvd; + } + + public void addPacketsSent(int pktSent) { + this._totPacketsSent += pktSent; + } + + public void addPacketsRcvd(int pktRcvd) { + this._totPacketsRcvd += pktRcvd; + } + + @Override + void grabList(List list) { + super.grabList(list); + Main.register(this); + } + + @Override + void releaseList(boolean terminalCallback) { + if (!terminalCallback) { + Main.unregister(this); + } + + super.releaseList(terminalCallback); + } + + @Override + public void mainCallback() { + int thisTime = Std.getFastTime(); + if (thisTime - this._lastTime > 1000) { + this.updateList(); + this._lastTime = thisTime; + } + } + + @Override + void createList() { + this._grabbedList.add("Drones Referring to Current Server:", 0); + this._grabbedList.add("", 1); + Pilot p = Pilot.getActive(); + Room r = p.getRoom(); + NetworkRoom netRoom = null; + if (r != null) { + netRoom = r.getNetworkRoom(); + } + + WorldServer ws = null; + if (netRoom != null) { + ws = netRoom.getServer(); + } + + if (ws != null) { + Vector<String> list = ws.printDroneReferrers(); + + for (int i = list.size() - 1; i >= 0; i--) { + String name = list.elementAt(i); + this._grabbedList.add(name); + } + } + } + + @Override + void updateList() { + this._grabbedList.removeAll(); + this.createList(); + } +} |