Author | Message | Time |
---|---|---|
mime | Hello, I create a simple chat client for bnet. I'am use http://code.google.com/p/javaop/source/browse/trunk/javaop2/javaop2/src/util/BNetPacket.java for creating packet. I refer as follows: [code] // [0x50] SID_AUTH_INFO //... DataOutputStream out = new DataOutputStream(...); // ... // create packet BNetPacket packet = new BNetPacket((byte) 0x50); packet.addDWord(0); packet.addDWord(PlatformsID.PLATFORM_IX86); packet.addDWord(ProductsID.D2XP); packet.addDWord(0x0C); packet.addDWord(0); packet.addDWord(0); packet.addDWord(0); packet.addDWord(0); packet.addDWord(0); packet.addNTString(locale.getISO3Country()); packet.addNTString(locale.getDisplayCountry()); // send game protocol byte out.writeByte(0x01); out.flush(); // send packet out.write(packet.getBytes()); out.flush(); [/code] I have a question, how receive and parse packet? I wrote: [code]DataInputStream in = new DataInputStream(...); System.out.println(in.read()); //PING System.out.println(in.read()); //Logon Type System.out.println(in.read()); //Server Token System.out.println(in.read()); // UDPValue** System.out.println(in.read()); // MPQ filetime System.out.println(in.read()); // IX86ver filename System.out.println(in.read()); // ValueString [/code] and the output i see: [code] 255 37 8 0 159 160 97 [/code] How to get the code and data packets from the packet in the normal view? Thanks. | November 17, 2009, 11:29 PM |
mime | November 18, 2009, 4:24 PM | |
Imperceptus | What was the solution? I have no clue about java but would be interested to know. | November 18, 2009, 5:54 PM |
mime | [quote author=Imperceptus link=topic=18114.msg183715#msg183715 date=1258566867] What was the solution? I have no clue about java but would be interested to know. [/quote] [code] //... BNetInputStream stream ... byte magic; do { magic = stream.readByte(); } while(magic != (byte)0xFF); int packetId= stream.readByte() & 0x000000FF; System.out.println(Integer.toHexString("Receive packet: 0x" + packetId)); int packetLength = stream.readWord() & 0x0000FFFF; byte [] data = new byte[packetLength-4]; for(int i = 0; i < packetLength-4; i++) { data[i] = stream.readByte(); } BNetInputStream auth = new BNetInputStream(new ByteArrayInputStream(data)); Integer nlsRevision = auth.readDWord(); System.out.println("nlsRevision: " + nlsRevision); int serverToken = auth.readDWord(); System.out.println("Server Token:" + serverToken); auth.skip(4); long mpqFileTime = auth.readQWord(); System.out.println("MPQ Filetime: " + mpqFileTime); String mpqFileName = auth.readNTString(); System.out.println("MPQ Filename: " + mpqFileName); byte[] valueStr = auth.readNTBytes(); System.out.println(valueStr); [/code] | November 18, 2009, 6:24 PM |
rabbit | [quote author=Imperceptus link=topic=18114.msg183715#msg183715 date=1258566867] What was the solution? I have no clue about java but would be interested to know. [/quote]The solution was copypasta with no learning. | November 19, 2009, 3:32 PM |