NetConnection problem

Hi board,

I wrote the following lines of code:

class Connector {
public function Connector(gatewayURI:String, connectNow:Boolean) {

// Dynamic class include for NetServices.as and NetDebug.as
Includes.getInstance();
isConnected = false;

//Init all services
this.servicePath = "ServiceProvider";

// Init gatewayURI
this.gatewayURI = gatewayURI;

gatewayConn_nc = new NetConnection();

// Init all handlers
gatewayConn_nc.onStatus = gatewayConnStatus;

//Immediately connect
if ( connectNow == true ) this.connectToGateway(); 
}

public function gatewayConnStatus(pInfo) {
trace("StatusGWConn: " + pInfo.code);
//if ( pInfo.code != NetServices.
}

public function connectToGateway() {
trace("Connecting to gateway...");
gatewayConn_nc.connect(gatewayURI);
}

public function closeConnection() {
gatewayConn_nc.close();
}

public function getRemoteService(serviceName:String, responder:Object):Object {
//Should do some sorta error handling

//if ( ! isConnected ) return null;
var service = gatewayConn_nc.getService(serviceName,this);
return service;
}
}

I have omitted some lines for brevity.
This is how i call:

var connector:Connector;

connector = new Connector("http://localhost:8223/mx/gateway",false);
connector.connectToGateway();
var service = connector.getRemoteService("some");
service.getObject(); // <-- until i call this the event is not fired

The problem is that the gatewayConnStatus is not triggered until i call the service.getObject(). And thus i have no means to try and determine if the server is up or not.

Help.

Cruiser.

[edit by kode]Please use the ActionScript tag [AS][/AS] to show your code.[/edit]