1 |
import java.io.*; |
2 |
import java.net.*; |
3 |
import java.util.*; |
4 |
|
5 |
public class UDPReaderThread extends Thread{ |
6 |
|
7 |
public UDPReaderThread(DatagramPacket packet){ |
8 |
try { |
9 |
xml = new String(packet.getData()); |
10 |
} |
11 |
catch (Exception e) { |
12 |
System.out.println("An exception occured while attempting to return an XMLPacket!"); |
13 |
e.printStackTrace(); |
14 |
} |
15 |
} |
16 |
|
17 |
public void run(){ |
18 |
|
19 |
System.out.println("UDPReaderThread - Received the following raw stuff: "+xml); |
20 |
|
21 |
XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml); |
22 |
XMLPacket packet = xmlPacketMaker.createXMLPacket(); |
23 |
|
24 |
if (packet == null){ |
25 |
System.out.println("UDPReaderThread - A null XMLPacket was returned, I think I'll ignore it!"); |
26 |
return; |
27 |
} |
28 |
System.out.println("UDPReaderThread - An XML Packet was read sucessfully: -"); |
29 |
packet.printAll(); |
30 |
// Now do something with this XMLPacket!!! |
31 |
// .... |
32 |
} |
33 |
|
34 |
String xml; |
35 |
} |