开发者

how to implement a websocket server with node.js?

are there any examples? And how 开发者_开发知识库node.js communicates with traditional php scripts ?


Take a look at socket.io. This includes a client and a server-side library.

http://socket.io


Well, you should read the (now deprecated) Specification.

For a straight forward implementation you can take a look at my code here:
https://github.com/BonsaiDen/NodeGame-Shooter/blob/master/server/nodegame/ws.js

If you like to have a big wall of abstraction with a trillion fall backs, take a look at: http://socket.io/

BUT...

Keep in mind when building your own one, the WebSocket protocol is about to change due to recently discovered security vulnerabilities:
http://hacks.mozilla.org/2010/12/websockets-disabled-in-firefox-4/
http://blog.pusherapp.com/2010/12/9/it-s-not-websockets-it-s-your-broken-proxy

As for the PHP part, it's unclear to me what you exactly want to do you should give us more information about that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜