实时更新网页 [英] Updating Webpage in Real Time

查看:91
本文介绍了实时更新网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作类似于风险的基于浏览器的多人回合制策略游戏.

I'm in the process of making a browser based multiplayer turnbased strategy game similiar to Risk.

目前,做事的最简单方法似乎就是使其像常规网页一样.玩家每次刷新时,网页都会查询数据库以获取所需的信息.

Right now, the easiest way to do things seems to be to just make it like a regular webpage. Each time a player refreshes, the webpage queries the database for the information it needs.

这是可以接受的,但是我宁愿实时更新页面,因此玩家不必不断刷新页面.

This is acceptable, but I'd MUCH rather have the page update in real time so the players don't have to constantly refresh the page.

我可以让网页每X秒查询一次数据库,但是我听说这样做效率不高.

I could just have the web page query the database every X seconds, but I've heard this isn't efficient.

做到这一点的最佳方法是什么?

What would be the best way to do this?

推荐答案

尝试 Socket.io 库或 Juggernaut2 . 您需要一个 Redis 适配器才能使用Juggernaut2,请看

Try Socket.io library or Juggernaut2. You will need a Redis adapter to use Juggernaut2, take a look at PhpRedis.

这篇关于实时更新网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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