6 |
|
|
7 |
|
public UDPReaderThread(DatagramPacket packet){ |
8 |
|
try { |
9 |
< |
xml = new String(packet.getData()); |
9 |
> |
rawPacket = packet.getData(); |
10 |
|
} |
11 |
|
catch (Exception e) { |
12 |
|
System.out.println("An exception occured while attempting to return an XMLPacket!"); |
15 |
|
} |
16 |
|
|
17 |
|
public void run(){ |
18 |
+ |
|
19 |
+ |
String xml = new String(rawPacket); |
20 |
+ |
xml = xml.substring(0, xml.indexOf(0)); |
21 |
+ |
|
22 |
+ |
System.out.println("UDPReaderThread - Received the following raw stuff: "+xml); |
23 |
+ |
|
24 |
|
XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml); |
25 |
|
XMLPacket packet = xmlPacketMaker.createXMLPacket(); |
26 |
+ |
|
27 |
+ |
if (packet == null){ |
28 |
+ |
System.out.println("UDPReaderThread - A null XMLPacket was returned, I think I'll ignore it!"); |
29 |
+ |
return; |
30 |
+ |
} |
31 |
+ |
System.out.println("UDPReaderThread - An XML Packet was read sucessfully: -"); |
32 |
+ |
packet.printAll(); |
33 |
+ |
// Now do something with this XMLPacket!!! |
34 |
+ |
// .... |
35 |
|
} |
36 |
|
|
37 |
< |
String xml; |
37 |
> |
byte[] rawPacket; |
38 |
|
} |