diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/StatNetMUNode.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/console/StatNetMUNode.java')
| -rw-r--r-- | NET/worlds/console/StatNetMUNode.java | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/NET/worlds/console/StatNetMUNode.java b/NET/worlds/console/StatNetMUNode.java new file mode 100644 index 0000000..b636341 --- /dev/null +++ b/NET/worlds/console/StatNetMUNode.java @@ -0,0 +1,92 @@ +package NET.worlds.console; + +import NET.worlds.core.Std; +import java.awt.List; + +public class StatNetMUNode extends StatMan implements MainCallback { + private static StatNetMUNode _singleInstance = new StatNetMUNode(); + 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 BLANK1 = 1; + private static final int TOTBYTESSENT = 2; + private static final int TOTBYTESRCVD = 3; + private static final int BLANK2 = 4; + private static final int TOTPKTSSENT = 5; + private static final int TOTPKTSRCVD = 6; + + public static StatNetMUNode getNode() { + return _singleInstance; + } + + private StatNetMUNode() { + StatNetNode.getNode().addChild(this); + } + + @Override + public String toString() { + return "Multiuser Server Connections"; + } + + 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("Overall Multiuser Server Network Statistics:", 0); + this._grabbedList.add("", 1); + this._grabbedList.add(" Total bytes sent: " + this._totBytesSent + " bytes", 2); + this._grabbedList.add("Total bytes received: " + this._totBytesRcvd + " bytes", 3); + this._grabbedList.add("", 4); + this._grabbedList.add(" Total packets sent: " + this._totPacketsSent + " packets", 5); + this._grabbedList.add("Total packets received: " + this._totPacketsRcvd + " packets", 6); + } + + @Override + void updateList() { + this._grabbedList.replaceItem(" Total bytes sent: " + this._totBytesSent + " bytes", 2); + this._grabbedList.replaceItem("Total bytes received: " + this._totBytesRcvd + " bytes", 3); + this._grabbedList.replaceItem(" Total packets sent: " + this._totPacketsSent + " packets", 5); + this._grabbedList.replaceItem("Total packets received: " + this._totPacketsRcvd + " packets", 6); + } +} |