Here is some code of what I am using today:
private function startAliveDeadCheck():void {
startMonitor("127.0.0.1", 80);
}
private function startMonitor(location:String, port:uint):void {
monitor = new SocketMonitor(location, port);
monitor.addEventListener(StatusEvent.STATUS, checkStatus);
monitor.pollInterval = 1000; // every second
monitor.start();
}
private function checkStatus(e:StatusEvent):void {
if (monitor.available) {
connectFlag.text = "ONLINE";
} else {
connectFlag.text = "OFFLINE";
}
}
The code works fine if you are monitoring one and only one socket. I wanted
to modify the code to handle a bindable arraycollection but can never seem to
pull the data out. I try changing the first function to use this:
[Bindable] private var socketsToMonitor:ArrayCollection = new ArrayCollection([
{ip:"127.0.0.1", port:80, aliveOrDead:false, monitor:},
{ip:"127.0.0.1", port:8080, aliveOrDead:false, monitor:}
]);
everything is fine. but I hit errors when trying to pull out each array and
starting a monitor on it. I tried
for each (item in socketsToMonitor) {
trace(it...@ip);
}
I get an [Object object] and not the IP address. Any idea's of where I am
going wrong. Once I even achieve this I am assuming my attempt to monitor
function will need to be redone. I welcome any pointers and thanks for the
help.
-ray