Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
insultcomicdog
Posts: 42
Registered: ‎01-05-2011
My Device: Not Specified

Testing WIFI Connectivity...Disconnect NAT on Simulator or Disconnect WIFI on Host Computer?

Hey All,

 

I've been trying to test WIFI connectivity of my app, ie goaltending for when WIFI is not available.... I get different results when 1) my host computer WIFI is not connect to a network and 2) when my host computer is connect to a network, and I just disconnect the NAT adaptor in VMWare....

 

When my host computer is not connected to a network, the app responds correctly both stand alone and through the simulator....If I make a server call in the app, the response is null and the correct error message shows up.

 

If I leave my host computer connected to a network, and disable the NAT in the simulator and make a server call in my app it just suspends.....If I disconnect the host computer from a network, then reconnect the NAT then I get the correct error messaging....

 

It's as if when the NAT is disabled, the server call is never made....What's makes this difficult to debug is that when the NAT is disabled, I can no longer get traces through the debug player....

 

If my app is responding properly when the host computer is not connected to a network, is that enough to test WIFI connectivity?

 

How is everyone else testing WIFI connectivity??

 

SMJOHN

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Testing WIFI Connectivity...Disconnect NAT on Simulator or Disconnect WIFI on Host Computer?

hey,

 

how are you checking the status of the network connection? below is a sample code i use to check for net connectivity. it seems to work all the time accurately:

 

NetworkTets.as:

package
{
import air.net.ServiceMonitor;
import air.net.URLMonitor;

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.MouseEvent;
import flash.events.StatusEvent;
import flash.net.URLRequest;
import flash.text.TextFieldAutoSize;

import qnx.ui.buttons.LabelButton;
import qnx.ui.text.Label;

public class NetworkTest extends Sprite
{
private var myBtn:LabelButton;
private var myLabel:Label;

public function NetworkTest()
{
super();

// support autoOrients
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

myBtn = new LabelButton();
myBtn.setPosition(10,10);
myBtn.label = "Start Test";
myBtn.setSize(150, 50);

myBtn.addEventListener(MouseEvent.CLICK, onClick);

addChild(myBtn);

myLabel = new Label();
myLabel.text = "Status: Not Started";
myLabel.autoSize = TextFieldAutoSize.LEFT;
myLabel.setPosition(10,60);

addChild(myLabel);
}

private function onClick(e:MouseEvent):void
{
startTest();
}

private function startTest():void
{
var urlMonitor:URLMonitor;
var urlRequest:URLRequest = new URLRequest( "http://google.com" );
urlMonitor = new URLMonitor( urlRequest );
urlMonitor.addEventListener( StatusEvent.STATUS, onStatusEvent );
urlMonitor.start();

}

private function onStatusEvent(e:StatusEvent):void
{
myLabel.text = "Status: " + e.code;

}
}
}

 

If you run that code there should be a button that shows up to click and it will tell you the status of the net connection. and when you disconnect, it should update the status with the disconnected status. you can easily change it to work with different Events such as ENTER_FRAME, etc. hope that helps some. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Contributor
insultcomicdog
Posts: 42
Registered: ‎01-05-2011
My Device: Not Specified

Re: Testing WIFI Connectivity...Disconnect NAT on Simulator or Disconnect WIFI on Host Computer?

I'm using the following listeners when I make a server call:

 

IOErrorEVENT and SecuritErrorEvent....

 

 

loader.addEventListener(Event.COMPLETE,onComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR,retry);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onError);
loader.addEventListener(ProgressEvent.PROGRESS,onProgress);

 

 

They work fine standalone and through the simulator when my host computer WIFI is disconnected from the network....It's when the NAT of the simulator is disconnected that things start acting up...

 

JRab...

 

With your method do I just make a URLrequest ONCE when I launch my app at the begining, and will the onStatusEvent be called whenever the PlayBook connects and disconnects for the duration the app is running? Or do you have to keep polling the server on a regular interval?

 

How are you testing lack of WIFI? Disabling NAT in the simulator or disconnecting WIFI on the host computer? I'm still not sure why my method wouldn't work....

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Testing WIFI Connectivity...Disconnect NAT on Simulator or Disconnect WIFI on Host Computer?

back before when i used this it worked like a charm. as soon as i disconnect or reconnect (laptop wifi connection) it'd pop up with a notfication that it disconnected. now i re-did some tests to confirm things but they arent consistent as they were before. i dont know if the simulator difference has anything to do with it. back when it worked, i was using the older sim. havent done tests on the new one till now.

 

but idealistically once the monitor starts it dispatches the statusevent when the connection status changes. and i tried doing the disconnect network adapter in vmware. the results varied but basically it'd pick up hte disconnect about a minute after i disconnected the adapter. but it would detect that i reconnected after that.

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.