使用PHP,JS,CSS和HTML创建一个类似活页签的Web应用程序? [英] Creating a live checkers-like web app with PHP, JS, CSS and HTML?

查看:180
本文介绍了使用PHP,JS,CSS和HTML创建一个类似活页签的Web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个现场的,类似棋盘的应用程序,它将工作如下:在这个棋盘上将显示多个图标/化身。我想在这个板子下面有一个命令提示符,或者一些其他类型的接口,这将允许他们控制某个头像,并得到它预制的动作。 多个用户将一次使用它,我将能够查看其他用户对棋盘的更改/操作。

I want to create a live, checkers-like app, which will work like this: There will be multiple icons/avatars displayed on this checkerboard like surface. I want to have a command prompt beneath this board, or some other sort of interface, that will allow them to control a certain avatar, and get it to preform actions. Multiple users will be using it at one time, and I will all be able to view the other user's changes/actions to the checkerboard.

我想知道的是:最好的方法是什么?我有我的HTML,CSS和JS方法,但不是我的数据存储方法。我知道,使用PHP,我有选择使用:基于文件的存储,MYSQL或一些其他的方法。我需要知道哪个更好,因为我不想有服务器迟滞,响应时间不足或一些其他问题,特别是在这种情况下,因为操作将执行每隔一秒2个左右,由这些多个用户。

What I'm wondering is: what's the best way to do this? I've got my HTML, CSS, and JS approach down, but not my data storage method. I know that, using PHP, I've got the choices to use either: file-based storage, MYSQL, or some other method. I need to know which is better, because I don't want to have server-lag, poor-response time, or some other issue, especially in this case since actions will be preformed every other second 2 or so, by these multiple users.

我以前做过类似的事情,但我想听听别人如何处理它(建议等)从更有经验的程序员。

I've done similar stuff before, but I'm wanting to hear how others would handle it (advice, etc.) from more experienced programmers.

推荐答案

听起来像一个伟大的项目node.js!

Sounds like a great project for node.js!

node.js是服务器端的javascript实现。你需要的是一个基于彗星的应用程序(基于Web的客户端应用程序接收服务器端推送,而不是客户端不断地轮询服务器),这是node.js是擅长的。

To clarify, node.js is a server-side implementation of javascript. What you'll want is a comet based application (a web-based client application that receives server side pushes instead of the client constantly polling the server), which is exactly what node.js is good at.

传统的ajax要求您的客户端轮询数据的服务器。这对客户端和服务器都产生了巨大的开销。允许服务器直接将请求推送到客户端,而不需要客户端反复请求解决开销问题,并创建一个更响应的接口。这通过在服务器上保持异步客户端连接来实现,并且仅当服务器有响应时才返回。一旦服务器响应数据,服务器就立即创建另一个连接并由服务器保存,直到数据准备好发送。

Traditional ajax calls for your clients to poll the server for data. This creates enormous overhead for both the client and the server. Allowing the server to push requests directly to the client without the client repeatedly asking solves the overhead issue and creates a more responsive interface. This is accomplished by holding asynchronous client connections on the server and only returning when the server has something to respond with. Once the server responds with data, another connection is immediately created and held by the server again until data is ready to be sent.

你可以用PHP完成同样的事情,但我不熟悉PHP和Comet类型的应用程序。

You may be able to accomplish the same thing with PHP, but I'm not that familiar with PHP and Comet type applications.

用户数和托管费用将在您的文件和数据库选项中播放。如果你计划超过几个用户,我会坚持数据库。有一些NoSQL选项可用,但在我的经验MySQL比这些选项更快,更可靠。

Number of users and hosting costs will play into your file vs DB options. If you're planning on more than a couple of users, I'd stick to the database. There are some NoSQL options available out there, but in my experience MySQL is much faster and more reliable than those options.

祝您的项目顺利!

http://en.wikipedia.org/wiki/Comet_%28programming%29

http://www.nodejs.org/

http://zenmachine.wordpress.com/2010/ 01/31 / node-js-and-comet /

http://socket.io/ - 根据客户端的能力抽象出客户端的通讯层( LongPolling WebSockets 等)

http://socket.io/ - abstracts away the communication layer with your clients based on their capability (LongPolling, WebSockets, etc.)

这篇关于使用PHP,JS,CSS和HTML创建一个类似活页签的Web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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