使用 websockets 和 websockets 创建在线白板应用程序HTML5?
我计划使用 HTML5、php、websockets、jQuery 和MySql 作为后端(如果需要保存等)。 但是,我之前没有 websocket 经验。 这是我找到的一个例子: http://www.codeproject.com/KB/aspnet/WebSocketWhiteBoard.aspx 然而,他们正在从本地服务器获取网络套接字。我希望使用提供的 websocket API。 http://dev.w3.org/html5/websockets/ 我们需要从客户和客户之间的握手开始。服务器。你能帮我看看我该怎么做吗? 谢谢!
I plan to use HTML5, php, websockets, jQuery & MySql as backend (if saving, etc is required).
However, I have no prior experience in websockets.
This is an example I found:
http://www.codeproject.com/KB/aspnet/WebSocketWhiteBoard.aspx
However they are taking websockets from localserver. I wish to use the websocket API provided.
http://dev.w3.org/html5/websockets/
We need to begin with a handshake between the client & server. Can you help me as to how I can do so?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以查看 PHP WebSocket、apache-websocket/
mod_websocket
,您可以使用单独的 自托管实时 Web 解决方案 或查看 < a href="http://www.leggetter.co.uk/real-time-web-technologies-guide#hosted-services" rel="nofollow noreferrer">托管实时服务,例如 Pusher(我为之工作)。关于使用 WebSockets、PHP 和相关技术有很多类似的问题,我建议您查看一下:
You could look at PHP WebSocket, apache-websocket/
mod_websocket
, you could use a separate self hosted realtime web solution or look at a hosted realtime service such as Pusher (who I work for).There are a number of similar questions about using WebSockets, PHP and related technologies which I recommend you take a look at:
除非您使用像
node.js
这样的东西作为您的网络服务器(并且您计划使用 PHP,我认为情况并非如此),否则您实际上需要一个单独的 WebSocket 服务器也是如此。如果您在自己的硬件上运行,那应该没问题,但您不太可能找到一个标准的 ISP Web 主机来为您提供运行您自己的服务器守护程序的能力。
有许多可用的 WebSocket 服务器和/或库可以执行 WebSocket 协议握手。我使用了为
node.js
编写的一个,但不幸的是 WS 规范仍在经历一些更改,并且它不再与 Chrome 兼容。另外,不要对 Socket.IO 感到困惑,很多人称之为“WebSockets”——它不是——它是一种更通用的通信方法,看起来有点像 WebSockets,并且可能使用真正的 WebSockets 作为它的传输层,但实际上是完全不同的协议。
Unless you're using something like
node.js
as your web server (and as you're planning to use PHP I presume that's not the case) you actually need a separate WebSocket server too.If you're running on your own hardware that should be fine, but you're unlikely to find a standard ISP web-host offering you the ability to run your own servers daemons.
There are a number of WebSocket servers and/or libraries available that perform the WebSocket protocol handshake. I've used one that was written for
node.js
but unfortunately the WS specification was still going through some changes and it's no longer compatible with Chrome.Also, don't get confused by
Socket.IO
which many people refer to as "WebSockets" - it's not - it's a more general communications method that looks a bit like WebSockets, and may use real WebSockets as its transport layer, but is actually a different protocol altogether.