ress5609
12-30-2008, 06:00 AM
This seems like a very blatent issue that would effect everyone attempting to use 4.0.6, so maybe I'm doing it wrong, or it's already been found.
I used the ConnectAndLogin example that came with the installation and noticed that the onConnect event in the example code never gets triggered.
After some investigation, I found that in ElectroServer.as, no event is dispatched if the connection is successful.
Here's the function in ElectroServer.as:
public function onConnect(ev:Object):void {
isConnected = false;
var con:AbstractConnection;
for (var i:Number=0;i<connections.length;++i) {
con = connections[i];
if (con.getIsConnected()) {
isConnected = true;
break;
}
}
if (ev.success) {
} else {
var cone:ConnectionEvent = new ConnectionEvent();
cone.setAccepted(false);
cone.setEsError(Errors.FailedToConnect);
dispatchEvent(cone);
//notifyListeners(MessageType.ConnectionEvent, {target:this, success:false});
}
}
The part in question is the if statement at the end of the function. If event.success is true, then nothing happens, and a ConnectionEvent is only dispatched if the connection wasn't successful.
I tested this theory by modifying the code here to be this:
if(ev.success) {
var cone:ConnectionEvent = new ConnectionEvent();
cone.setAccepted(true);
cone.dispatchEvent(cone);
} else {
// unchanged
}
After making that change, the ConnectAndLogin example worked. Unless I'm doing something wrong, this seems to be a pretty big issue if no one can connect to the server without modifying the provided API manually.
I used the ConnectAndLogin example that came with the installation and noticed that the onConnect event in the example code never gets triggered.
After some investigation, I found that in ElectroServer.as, no event is dispatched if the connection is successful.
Here's the function in ElectroServer.as:
public function onConnect(ev:Object):void {
isConnected = false;
var con:AbstractConnection;
for (var i:Number=0;i<connections.length;++i) {
con = connections[i];
if (con.getIsConnected()) {
isConnected = true;
break;
}
}
if (ev.success) {
} else {
var cone:ConnectionEvent = new ConnectionEvent();
cone.setAccepted(false);
cone.setEsError(Errors.FailedToConnect);
dispatchEvent(cone);
//notifyListeners(MessageType.ConnectionEvent, {target:this, success:false});
}
}
The part in question is the if statement at the end of the function. If event.success is true, then nothing happens, and a ConnectionEvent is only dispatched if the connection wasn't successful.
I tested this theory by modifying the code here to be this:
if(ev.success) {
var cone:ConnectionEvent = new ConnectionEvent();
cone.setAccepted(true);
cone.dispatchEvent(cone);
} else {
// unchanged
}
After making that change, the ConnectAndLogin example worked. Unless I'm doing something wrong, this seems to be a pretty big issue if no one can connect to the server without modifying the provided API manually.