Verification of user's existence in chat script

后端 未结 3 1673
一个人的身影
一个人的身影 2020-12-18 13:36

When ever user leaves chat page (Either by logging out or just by simple closing the browser window). Chat script instantly detects that user left and show offline sign. Thi

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 14:06

    The chat can send a logout message using the onunload event, which is triggered if the user leaves the page/closes the browser, however it is not reliable. A second option for the server is to begin a timeout countdown as soon as the underlying TCP connection is closed and show the user as "offline" in case he does not reconnect in time.

提交回复
热议问题