验证用户在聊天脚本中的存在 [英] Verification of user's existence in chat script

查看:141
本文介绍了验证用户在聊天脚本中的存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户何时离开聊天页面(通过注销或仅通过简单关闭浏览器窗口)。聊天脚本立即检测到该用户离开并显示脱机签名。这个过程在几秒钟之内就会发生这么真的工作原理吗?

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. This process takes place in few seconds how this really works?

我是一个ASP.NET / c#开发人员,除此之外我使用JavaScripts而很少使用PHP。请不要超过其他语言的答案。

I am an ASP.NET/c# developer apart from it I use JavaScripts and rarely PHP. Please don't exceed answer(s) to other languages.

推荐答案

让您的JavaScript聊天代码向服务器发送消息每2秒使用XMLHttpRequest。当您没有收到消息时,这表示用户已关闭窗口。

Just have your JavaScript chat code send a message to the server every 2 seconds using XMLHttpRequest. When you don't receive a message, that means that the user has closed the window.

这篇关于验证用户在聊天脚本中的存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆