Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_APP_TERMINATING on page exit #88

Closed
Beuc opened this issue Aug 14, 2019 · 2 comments

Comments

@Beuc
Copy link
Contributor

commented Aug 14, 2019

I'm considering how to save some of the game data when the player leaves the web page.

I believe that sending SDL_APP_TERMINATING on window.beforeunload, and offering the developer to catch it with a synchronous SDL_AddEventWatch() (the game won't have a change to run its event loop), would make the most sense in the SDL2 emscripten port.
https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
https://wiki.libsdl.org/SDL_EventType
https://wiki.libsdl.org/SDL_AddEventWatch

I'm going to do some testing, let me know if that's something you'd appreciate a PR for :)

@Daft-Freak

This comment has been minimized.

Copy link
Member

commented Aug 15, 2019

I think this came up while working on the initial port. There was an attempt at sending window close/quit events (gsathya/SDL-emscripten@4c2637c) which didn't work, but I wasn't aware of SDL_AddEventWatch back then.

@Beuc

This comment has been minimized.

Copy link
Contributor Author

commented Aug 16, 2019

I pushed #89.
Please find attached a test app :)
testbeforeunload.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.