till now i don't know the reason why onDisconnect Event handler doesn't work when user disconnect due to power cut off OR by disabling net-connection. But i found another way to identify it.Below is the code for accepting the client conection and then after each 15 seconds I am checking if the client is still active (after loosing net-connection) then disconnect it and we get "NetConnection.Connect.Closed" on client side.
application.allowDebug = true;
application.onAppStart = function(){
application.users_so = SharedObject.get("SO");
}
application.onConnect = function(client,Obj){
client.name = Obj.name;
application.acceptConnection(client);
application.users_so.setProperty(client.name,Obj);
client.interval = setInterval(checkLive, 15000, client);
trace("one user is now connected.");
}
function checkLive(client){
var stats = client.getStats();
trace('Measured timeout: ' + stats['ping_rtt']);
if(stats){
if(stats['ping-rtt']>10){
trace('client '+ client.name +'is still connected.');
application.disconnect(client);
}
}
}
application.onDisconnect = function(client){
clearInterval(client.interval);
trace(" user lost connection.");
}