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

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

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -