I'm attempting to make a session pause in the onbeforeunload event but
running into issues with the browser prematurely closing connections (both
xhr and script). Here is roughly the series of events:

app.onPageUnload()
  con.pause( 120 )
    beforepause handler: con.send( new Message( "[EMAIL PROTECTED]", "brb..." )
)
    con.send( "<body rid="1234" pause="120" .../>" )
    lastRid = 1234 // the RID of the last packet; the pause request

=== reload page ===

app.onPageLoad()
  con.resume( lastRid (=1234), etc )
    con.send( "<body rid="1235" .../>" )  // first request, poll or normal;
the RID after the pause request
    resume handler: con.send( new Message( "[EMAIL PROTECTED]", "back" ) )

This works as expected if i manually call app.onPageUnload(), refresh the
page, and call app.onPageLoad(). But as soon as I have app.onPageUnload()
called from the onbeforeunload handler of the page, all script and xhr
connections seem to prematurely close. Also, I get correct behavior if I put
a breakpoint after all requests are sent in the app.onPageUnload function
(ie connections are left open long enough to fully transmit their contents).

If connections prematurely close but I decrement the rid by 1 on the resume
request then the connection resumes as expected.

Since this works as expected outside the onbeforeunload handler, I assume
that the problem is unexpected behavior due to connections closing
prematurely.

Does anyone have ideas for how to work around this?

Thanks,

Harlan

Reply via email to