I have a .NET console app that reads info from a USB stick and spits it out. I have an AIR app that listens to it and processes the information.
My problem is that sometimes my air app doesn’t seem to process some of the messages, even though the log shows that they were sent from the .net console app.
Here’s what I’m doing.
.NET
Trace.WriteLine("heart," & heartRate & "," & GetTimeStamp() & ",")
I have a bunch of different listeners that spit out information. I’m just sending them through with commas separating the values. I added a comma to the end just to make sure I would spit the array if two lines were picked up at once on the air side (can that even happen?)
AIR
public function ProcessConsoleData(data:String):void{
var tempArray:Array = data.split(",");
var pointUpdated:Boolean = false;
if (tempArray[0] == ("heart")){
if (_dataModel.DeviceHeartRate.IsDeviceAvailable != true){
_dataModel.DeviceHeartRate.IsDeviceAvailable = true;
}
_dataModel.DeviceHeartRate.HeartRate = int(tempArray[1]);
_dataModel.DeviceHeartRate.LastUpdate = tempArray[2] as Date;
}
The process console data function continues like that with about 25 else if statments with different values for tempArray[0] (Yes I know the ‘right’ thing to do is use a case statement but I like it with else ifs).
Data comes at the app pretty fast. Sometimes just 100ms or maybe less (haven’t done any benchmarks). Sometimes the air app won’t process the data that’s sent. I don’t know why and it’s hard to debug.
Does anyone have a better way to maintain message fidelity from .NET to AIR? Maybe someone can see a hole in my logic?
Thanks.
-Nate
Which method do you use? Two apps can be connected through local network, but there is simpler way. AIR can run console app itself with
NativeProcessand communicate with it via stdin|stdout. This makes console application child process of AIR app (AIR cannot connect to running console app this way).