简体   繁体   English

计时器可由多个用户查看

[英]Timer Viewable by multiple users

Im am currently developing a simple game that requires a timer. 我目前正在开发一个需要计时器的简单游戏。 Currently the timer i have only displays for the specific user looking at the page. 目前,我只为查看该页面的特定用户显示计时器。 I want the timer to be the same for all of the users not different for each user. 我希望所有用户的计时器都相同,而不是每个用户都不同。 Could someone please point me to an example of something like this? 有人可以给我指出一个这样的例子吗? Thank You 谢谢

Javascript is client side, meaning that it will only run on each clients machine individually and not every clients simultaneously. Javascript是客户端,这意味着它将仅在每个客户端计算机上单独运行,而不是同时在每个客户端上运行。 For your countdown timer to be the same for multiple users you would have to use a server side language such as PHP. 为了使多个用户的倒数计时器相同,您必须使用服务器端语言,例如PHP。

Using PHP, along with Javascript or Jquery you could easily implement a system wide countdown timer, however if you only wanted certain users to have this timer you would have to put logic into your PHP code that would check which users are apart of the game. 使用PHP和Javascript或Jquery可以轻松实现系统范围的倒数计时器,但是,如果仅希望某些用户拥有此计时器,则必须在PHP代码中放入逻辑,以检查哪些用户与游戏无关。

Here is a link to a tutorial I found, should get your started in the right direction 这是我找到的教程的链接,应该以正确的方向开始

http://www.brighthub.com/internet/web-development/articles/9471.aspx http://www.brighthub.com/internet/web-development/articles/9471.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM