javascript - Websocket - send something before onclose is triggerd -


hello im realy new websockets, build webchat websockets , php socket server. store userdata use php-sessions.

i want unset session when user disconnects. when websocket onclose triggerd im not able send message (server allready closed or in close state) server.

is there nice way send client server before onclose happens?

thanks lot

it depends.

you can send right before closing window/tab onbeforeunload event. or if have deterministic close function in app buttons "disconnect", "close", "connect somewhere else"... etc..., have ensure send whatever want before closing.

but there nothing "onbeforeclose": https://developer.mozilla.org/en-us/docs/web/api/websocket


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -