Faye dies when user leaves page but then chooses to stay on page through JS confirmation

StackOverflow https://stackoverflow.com/questions/8054175

  •  24-02-2021
  •  | 
  •  

質問

Using Faye for active client connections. I have my users confirm to leave page through some JS:

window.onbeforeunload = page_leave; 
function page_leave() { 
        return "All open sessions will be disconnected."; 
}

If the user chooses to stay on the page, faye no longer works. (Messages are no longer sent or received.) Perhaps there is something in faye.js that kills the connection in the onbeforeunload event? Is there a way around this?

I'm using Chrome on OSX. Happens every time. Haven't tested other browsers yet.

役に立ちましたか?

解決

Looks like faye closes connections in the beforeunload event. Topic has been discussed here: http://groups.google.com/group/faye-users/browse_thread/thread/83165b2c6e30af8a

UPDATE: In newer versions of Faye there is an option to turn this off:

client.disable('autodisconnect');
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top