开发者

Where should i write my clean up tasks in JApplet?

I am creating a chat application using JApplet. I created socket in init() method and everything seems to work fine. Now i want to send message开发者_JAVA百科 "user has left the room" when he closes the window (in which JApplet resides) as well as also close the sockets.

I wrote my cleanup tasks in destroy() method. But they don't seem to work. Where is the correct place to write this logic, so that it works in all possible cases like user closes browser's close button or navigates to a different page?

Thanks in advance :)


Tried overriding stop() ?


I assume you have some way of keeping track of whether the user is still logged into the room. If you build in an inactivity timeout period, you can automaticlaly log the user out if the user is inactive for the specified period.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜