summaryrefslogtreecommitdiff
path: root/NET/worlds/network/netPacketReader.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/network/netPacketReader.java
downloadworlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz
worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/network/netPacketReader.java')
-rw-r--r--NET/worlds/network/netPacketReader.java357
1 files changed, 357 insertions, 0 deletions
diff --git a/NET/worlds/network/netPacketReader.java b/NET/worlds/network/netPacketReader.java
new file mode 100644
index 0000000..4d7a479
--- /dev/null
+++ b/NET/worlds/network/netPacketReader.java
@@ -0,0 +1,357 @@
+/* */ package NET.worlds.network;
+/* */
+/* */ import NET.worlds.console.StatNetMUNode;
+/* */ import java.io.ByteArrayInputStream;
+/* */ import java.io.IOException;
+/* */ import java.io.PrintStream;
+/* */ import java.util.Vector;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class netPacketReader
+/* */ extends Thread
+/* */ {
+/* */ private Vector<receivedNetPacket> _msgQ;
+/* */ private ServerInputStream _in;
+/* */ private WorldServer _serv;
+/* */ private static Class<receivedNetPacket>[] msgTable;
+/* */
+/* */ public netPacketReader(ServerInputStream in)
+/* */ {
+/* 95 */ this._in = in;
+/* 96 */ this._msgQ = new Vector();
+/* */ }
+/* */
+/* */ public netPacketReader(WorldServer serv, ServerInputStream in) {
+/* 100 */ this._serv = serv;
+/* 101 */ this._in = in;
+/* 102 */ this._msgQ = new Vector();
+/* 103 */ this._in.setVersion(getVersion());
+/* */ }
+/* */
+/* */
+/* */
+/* */ public void setVersion(int vers)
+/* */ {
+/* 110 */ this._in.setVersion(vers);
+/* */ }
+/* */
+/* */
+/* */
+/* */ public int getVersion()
+/* */ {
+/* 117 */ return this._serv.getVersion();
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public void put(receivedNetPacket pkt)
+/* */ {
+/* 126 */ this._msgQ.addElement(pkt);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public receivedNetPacket get()
+/* */ {
+/* 139 */ assert (this._msgQ != null);
+/* 140 */ if (this._msgQ.isEmpty()) {
+/* 141 */ return null;
+/* */ }
+/* 143 */ receivedNetPacket packet = (receivedNetPacket)this._msgQ.firstElement();
+/* 144 */ this._msgQ.removeElement(packet);
+/* 145 */ return packet;
+/* */ }
+/* */
+/* */ public int count()
+/* */ {
+/* 150 */ return this._msgQ.size();
+/* */ }
+/* */
+/* */
+/* */ static
+/* */ {
+/* 156 */ msgTable = new Class['ΓΏ'];
+/* */
+/* 158 */ String basePath = "NET.worlds.network.";
+/* */
+/* 160 */ Vector<String> cmdList = new netCmds().recvCmdList();
+/* */
+/* */
+/* */
+/* */
+/* 165 */ for (int i = 0; i < cmdList.size(); i++) {
+/* 166 */ String cmdName = basePath + (String)cmdList.elementAt(i);
+/* */
+/* */ try
+/* */ {
+/* 170 */ Class<receivedNetPacket> tmpCmdClass = Class.forName(cmdName);
+/* 171 */ receivedNetPacket tmpInstance = (receivedNetPacket)tmpCmdClass.newInstance();
+/* 172 */ int indx = tmpInstance.msgID();
+/* 173 */ assert (indx > -1);
+/* 174 */ assert (msgTable[indx] == null);
+/* 175 */ msgTable[indx] = tmpCmdClass;
+/* */
+/* */ }
+/* */ catch (NoSuchMethodError e)
+/* */ {
+/* */
+/* 181 */ synchronized (System.out) {
+/* 182 */ System.out.println("netPacketReader:: " +
+/* 183 */ e.getClass().getName() + " creating " + cmdName);
+/* 184 */ System.out.println("netPacketReader:: Exception: " +
+/* 185 */ e.getMessage());
+/* 186 */ e.printStackTrace(System.out);
+/* */ }
+/* 188 */ if (!$assertionsDisabled) throw new AssertionError();
+/* */ }
+/* */ catch (Exception e) {
+/* 191 */ synchronized (System.out) {
+/* 192 */ System.out.println("netPacketReader:: " +
+/* 193 */ e.getClass().getName() + " creating " +
+/* 194 */ cmdName);
+/* 195 */ System.out.println("netPacketReader:: Exception: " +
+/* 196 */ e.getMessage());
+/* 197 */ e.printStackTrace(System.out);
+/* */ }
+/* */
+/* 200 */ if (!$assertionsDisabled) { throw new AssertionError();
+/* */ }
+/* */ }
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ private final void buildMsg()
+/* */ throws IOException
+/* */ {
+/* 245 */ this._in.readPacketSize();
+/* */
+/* */
+/* */
+/* 249 */ byte[] packetData = new byte[this._in.bytesLeft() + 1];
+/* */
+/* 251 */ packetData[0] = ((byte)(this._in.bytesLeft() + 1));
+/* 252 */ this._in.readFully(packetData, 1, this._in.bytesLeft());
+/* */
+/* */
+/* 255 */ StatNetMUNode netStat = StatNetMUNode.getNode();
+/* 256 */ netStat.addBytesRcvd(packetData.length);
+/* 257 */ netStat.addPacketsRcvd(1);
+/* */
+/* */
+/* 260 */ ServerInputStream in = new ServerInputStream(new ByteArrayInputStream(
+/* 261 */ packetData));
+/* 262 */ in.readPacketSize();
+/* */
+/* 264 */ if ((WorldServer.getDebugLevel() & 0x800) > 0) {
+/* 265 */ synchronized (System.out) {
+/* 266 */ System.out.print(this._serv + ": recv[");
+/* 267 */ for (int i = 0; i < packetData.length; i++)
+/* 268 */ System.out.print(Integer.toString(
+/* 269 */ packetData[i] & 0xFF, 16) + " ");
+/* 270 */ System.out.println("]");
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* 276 */ receivedNetPacket packet = null;
+/* 277 */ ObjID objID = new ObjID();
+/* */
+/* 279 */ objID.parseNetData(in);
+/* */
+/* 281 */ boolean isCO = objID.shortID() == 254;
+/* */
+/* 283 */ int cmdType = in.readUnsignedByte();
+/* */
+/* 285 */ if ((cmdType >= msgTable.length) || (msgTable[cmdType] == null))
+/* */ {
+/* 287 */ System.out.println("UNKNOWN SERVER MSG#" + String.valueOf(cmdType));
+/* */
+/* 289 */ in.skipBytes(in.bytesLeft());
+/* 290 */ assert (in.isEmpty());
+/* */ }
+/* */ else
+/* */ {
+/* */ do {
+/* 295 */ if (isCO)
+/* */ {
+/* 297 */ objID = new ObjID();
+/* 298 */ objID.parseNetData(in);
+/* */ }
+/* */ try {
+/* 301 */ packet = (receivedNetPacket)msgTable[cmdType].newInstance();
+/* */ } catch (Exception e) {
+/* 303 */ System.out.println(e + ": " + e.getMessage());
+/* 304 */ if (!$assertionsDisabled) throw new AssertionError();
+/* */ }
+/* 306 */ packet.init(objID);
+/* */
+/* 308 */ packet.parseNetData(in);
+/* */
+/* */
+/* */
+/* */
+/* */
+/* 314 */ this._msgQ.addElement(packet);
+/* 315 */ yield();
+/* */ }
+/* 317 */ while ((!in.isEmpty()) && (isCO));
+/* 318 */ assert (in.isEmpty());
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public void run()
+/* */ {
+/* */ try
+/* */ {
+/* */ for (;;)
+/* */ {
+/* 342 */ buildMsg();
+/* */ }
+/* */
+/* */ }
+/* */ catch (IOException e)
+/* */ {
+/* 348 */ this._msgQ.addElement(new ExceptionCmd(e));
+/* */ }
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\netPacketReader.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file