diff options
Diffstat (limited to 'NET/worlds/network/netPacket.java')
| -rw-r--r-- | NET/worlds/network/netPacket.java | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/NET/worlds/network/netPacket.java b/NET/worlds/network/netPacket.java new file mode 100644 index 0000000..14afa2f --- /dev/null +++ b/NET/worlds/network/netPacket.java @@ -0,0 +1,124 @@ +/* */ package NET.worlds.network; +/* */ +/* */ import NET.worlds.console.StatNetMUNode; +/* */ import java.io.IOException; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public abstract class netPacket +/* */ { +/* */ protected ObjID _objID; +/* */ protected int _commandType; +/* */ +/* */ public netPacket(ObjID id, int cmd) +/* */ { +/* 62 */ if (id != null) { +/* 63 */ this._objID = id; +/* */ } else +/* 65 */ this._objID = new ObjID(1); +/* 66 */ this._commandType = cmd; +/* */ } +/* */ +/* */ public netPacket() { +/* 70 */ this._objID = new ObjID(1); +/* */ } +/* */ +/* */ public int msgID() { +/* 74 */ return this._commandType; +/* */ } +/* */ +/* */ int packetSize() +/* */ { +/* 79 */ return 2 + this._objID.packetSize(); +/* */ } +/* */ +/* */ public String toString(WorldServer serv) { +/* 83 */ return new Integer(this._commandType).toString(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ void send(ServerOutputStream o) +/* */ throws IOException +/* */ { +/* 92 */ int packetsize = packetSize(); +/* */ +/* 94 */ if ((packetsize >= 256) && (o.getVersion() <= 24)) { +/* 95 */ throw new PacketTooLargeException(); +/* */ } +/* */ +/* */ +/* */ +/* 100 */ StatNetMUNode netStat = StatNetMUNode.getNode(); +/* 101 */ netStat.addBytesSent(packetsize); +/* 102 */ netStat.addPacketsSent(1); +/* */ +/* 104 */ assert (this._commandType > 0); +/* */ +/* 106 */ if ((packetsize >= 128) && (o.getVersion() > 24)) +/* */ { +/* */ +/* 109 */ o.writeByte(128 + packetsize / 256); +/* 110 */ o.writeByte(packetsize & 0xFF); +/* */ } +/* */ else { +/* 113 */ o.writeByte(packetsize); +/* */ } +/* 115 */ this._objID.send(o); +/* 116 */ o.writeByte(this._commandType); +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\netPacket.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |