Got the live ac35 data working in paralell with the parse and the app.

#story[820]
This commit is contained in:
Kusal Ekanayake
2017-04-27 14:40:26 +12:00
parent 67a702ffcd
commit 104fd86179
5 changed files with 25 additions and 15 deletions
@@ -19,11 +19,11 @@ public class StreamPacket {
this.payload = payload;
//System.out.println("type = " + this.type.toString());
//switch the packet type to deal with what ever specific packet you want to deal with
if (this.type == PacketType.XML_MESSAGE){
//System.out.println("--------");
System.out.println(new String(payload));
StreamParser.parsePacket(this);
}
// if (this.type == PacketType.XML_MESSAGE){
// //System.out.println("--------");
// System.out.println(new String(payload));
// StreamParser.parsePacket(this);
// }
}
PacketType getType() {
@@ -29,21 +29,25 @@ public class StreamParser extends Thread{
private String threadName;
private Thread t;
StreamParser(String threadName){
public StreamParser(String threadName){
this.threadName = threadName;
}
public void run(){
try {
while (StreamReceiver.packetBuffer.size() <= 1) {
System.out.println("START OF STREAM");
while (StreamReceiver.packetBuffer == null || StreamReceiver.packetBuffer.size() < 1) {
Thread.sleep(1);
}
StreamPacket packet = StreamReceiver.packetBuffer.take();
while (packet != null){
while (StreamReceiver.packetBuffer.peek() != null){
StreamPacket packet = StreamReceiver.packetBuffer.take();
parsePacket(packet);
Thread.sleep(10);
packet = StreamReceiver.packetBuffer.take();
while (StreamReceiver.packetBuffer.peek() == null) {
Thread.sleep(1);
}
}
System.out.println("END OF STREAM");
} catch (Exception e){
e.printStackTrace();
}
@@ -39,9 +39,7 @@ public class StreamReceiver extends Thread {
});
packetBuffer = pq;
connect();
StreamParser streamParser = new StreamParser("TestThread2");
streamParser.start();
}
public void start () {