header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Asaf Koski
Points:0
Posts:0

3/9/2011 9:33:50 AM

Title: Problem Exiting an AIR application on the Mac


Hi,

I work at ICQ, and we develop a client version based on AIR for the Macintosh.
I currently have a problem and I can't find a proper solution.

The application is based on an HTTP client server protocol (AOL's WIM).
When the user wants to exit the application we need to hit a sign off URL, so users on the other side will know the user went offline immediately.

So I've started out by listening to the NativeApplication Event.EXITING, which catches all sorts of user exit methods on the Mac.
If the client is currently logged in, I do the following:
- Call the proper sign off URL request
- Call event.preventDefault(); so the application won't exit before the request complete
- When the event completes (or fails), call NativeApplication.exit();

All fine up to now.

The problem occurs when the user tries to logout from the Mac using Logout / Restart / Shutdown from the Mac's Finder menu.
Calling preventDefault on the event immediately aborts the user's logout operation, indicating ICQ prevents the computer from shutting down.

Unlike windows, which asks applications to close themselves, and then give them some time and check if they are already closed, the Mac probably waits for a response, and the AIR application returns something when preventing the event to complete.

My questions:
1. Is there a way to let the Mac logout operation continue and still wait for the event to complete?
2. On the other hand, Is there a way to make a synchronized URL request in flash? So I will know the request went through, and let the system logout if needed?
3. If there is no way, Is there a way to differentiate between receiving quit events from the system dock quit menu (Which I can't remove), and the top level finder commands (logout, restart, shutdown).

Note: I've tried using both URLLoader and sendToURL. Also tried both GET and POST.
The behavior is inconsistent. Sometimes the url request makes it but usually it doesn't.

Please help,
Thanks,
Asaf



1
Wilbur
Points: 510
Posts:0
3/9/2011 11:22:06 AM



to my understanding unusual behavior of the request is due to the fact that if you use preventDfault() you are just restricting the application from quitting but the system will stop the background services related to network. So sometimes the network services are still alive while request is made and received. In some cases the network service is immediately closed causing the request to stop.


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 2+4 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions