haxball / haxball-issues

115 stars 43 forks source link

room.onRoomClose #718

Closed AnddyAnddy closed 5 years ago

AnddyAnddy commented 5 years ago

Hey, is there a way to catch when the room closes or i believe harder, when the browser leaves the headless window ? Otherwise, would it be possible to add this feature ?

iamrenan commented 5 years ago

I'm not sure whether it's exactly what you want, but you can use window.onbeforeunload (see more info here: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#Syntax). When the headless tab is closed, this event is fired before that happens.

Em qui, 28 de mar de 2019 16:15, AnddyAnddy notifications@github.com escreveu:

Hey, is there a way to catch when the room closes or i believe harder, when the browser leaves the headless window ? Otherwise, would it be possible to add this feature ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/haxball/haxball-issues/issues/718, or mute the thread https://github.com/notifications/unsubscribe-auth/AIGC8CEB9q3pJl7EEgF7OW-vcxFIIk5Oks5vbRTkgaJpZM4cQ8os .

AnddyAnddy commented 5 years ago

Thanks, it's what i needed

olehmisar commented 5 years ago

I believe unload event is more relevant because it is fired when window is about to be closed and, unlike beforeunload, it cannot prevent window closing.