Also, watch out for the fact that BlazeDS automatically resets the session when 
it is invalidated, so if you do session.invalidate() within a remoteobject 
method on the server the current session will be invalidated but a new, empty 
session is automatically regenerated (i.e. request.getSession(true)). This is 
done in case there are any further messages in the current batch being 
processed that could potentially blow up during processing if there's a 
dependency on the session.

Using the trick Mete mentions below, you can call into your swf and invoke 
disconnectAll() on your channelSet. This will inform the server that the client 
is going away. The default behavior on the server in this scenario is to leave 
the current session in place in case the user has other apps/pages running that 
depend on it. But you can trigger a clean session invalidation (that will not 
create a new session) by adding the optional 'invalidate-session-on-disconnect' 
config setting to your endpoint. Eg.

<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint 
url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"; 
class="flex.messaging.endpoints.AMFEndpoint"/>
    <properties>
          
<invalidate-session-on-disconnect>true</invalidate-session-on-disconnect> 
    </properties>
</channel-definition>

When you handle a click of your logout button, you could just invoke logout() 
on your channelSet which will invalidate your server session, clear out any 
authed Principal, and leave you in a state where the user could log back in if 
they wished. 

Seth

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
meteatamel
Sent: Tuesday, May 20, 2008 5:37 AM
To: [email protected]
Subject: [flexcoders] Re: Is it possible to invoke a AMF call just before 
browser close?

I'd try onunload and onbeforeunload events to see they help. If that
doesn't help, I'd try putting up an Alert box before making the AMF
call to make sure AMF call is made before the browser is closed.

-Mete

--- In [email protected], "Dan" <[EMAIL PROTECTED]> wrote:
>
> Hi,
> 
> I am trying to invalidate a session by explicity invoke a AMF call 
> when the user click logout or closing the browswer.
> 
> By ExternalInterface, the CLOSE event is capture within the FLEX 
> correctly. But by tracing in the debugger, if a AMF is invoke upon 
> this, the call did invoke but the AMF call is not sent to through the 
> FDS, I wonder if the application is being killed before the FDS 
> successfully sent the request.
> 
> Is it not a good idea to invalidate a session in this way? Any 
> Flexpert suggestion? :>
> 
> Dan
>
 

Reply via email to