如何检查用户是否在特定页面中. [英] How to check if a user is in a specific page.

查看:46
本文介绍了如何检查用户是否在特定页面中.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


是否可以检查用户是否在特定页面中?
我有游戏室页面,我想做一个功能,
如果我有他的昵称的用户在此页面中,则每秒检查一次.
例如,我有一个昵称"Josh",我想检查Josh是否在页面"game.aspx"中.

有任何想法吗?

谢谢.

Hi,
Is it possible to check if a user is in a specific page?
I have game rooms page and I would like to do a function which
checks say every second if a a user which I have his nick is in this page.
For example I have the nick "Josh" and I want to check if Josh is in the page "game.aspx".

Any Ideas?

Thank you.

推荐答案

在没有客户端启动某些操作的情况下,服务器无法直接调用客户端.想一想.许多站点收集有关连接到其站点的客户端的信息.您想让他们中的任何人随时连接到您的Web浏览器吗?

您将需要一种机制,该机制使客户端每隔一定的时间向服务器发送ping指示它们仍然连接.
There is no way for the server to call a client directly without some action being initiated by the client. Think about it. Many sites collect information about the clients who connect to their site. Would you want anyone of them to connect to your web browser at any time?

You will need a mechanism that has the client send a ping to the server at certain intervals to indicate they are still connected.


您可以使用在页面中更新的会话变量.加载方法.
You could use a session variable that''s updated in the Page Load method.


,但是保存游戏状态的应用程序在退出浏览器时将保持为true,因此会表示他不在游戏中时仍在游戏中.
如果我只能在session_end发生时获取会话值,那一切都会很好

我正在尝试使用此代码

but the application which saves the game status will stay true when he exits the browser so it will say he is still in the game while he isn''t!
if i could just get the session value when session_end happens everything would be great

I am trying to use this code

if (Application["player1"] == Session["mynick"])
{
    Application["status1"] = false;
    Application["player1"] = "";
}




在session_end中,但当sassion ["mynick"]没有值时:<</xml>




in the session_end but when it happens sassion["mynick"] has no value :<</xml>


这篇关于如何检查用户是否在特定页面中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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