通过PHP和cURL访问NodeJS / Socket.io [英] Access NodeJS / Socket.io over PHP and cURL

查看:189
本文介绍了通过PHP和cURL访问NodeJS / Socket.io的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行nodejs / socket.io(v 0.7)服务器将数据推送到Web客户端。这很有效。



要扩展应用程序,我需要通过php触发/影响socket.io。我知道一个解决方案,使用cURL over http与nodejs http服务器。



一个可能的解决方案是运行socket.io服务器和nodejs http服务器在一个相同的app.js.客户端连接并与socket.io通信,并且唯一允许的连接到独立的http服务器(当然是在socket.io的另一个端口上监听)分别来自通过cURL的php服务器的127.0.0.1。 p>

因为这两个服务器在同一范围内,http服务器可以触发socket.io服务器上的事件。



我的问题:doest有什么意义吗?有没有更清洁的解决方案从PHP触发socket.io上的事件?

解决方案

我认为这是一个合理和直接的方式;似乎谨慎处理执行顺序,但这可能只是我的节点显示的不确定性。


I'm running a nodejs / socket.io (v 0.7) server to push data to web clients. That works greatly.

To extend the application, I need to trigger / influence socket.io over php. I know a solution that works with cURL over http with the nodejs http server.

One possible solution is to run the socket.io server and the nodejs http server in one an the same app.js. The clients connect and communicate with socket.io, and the only allowed connection to the "seperate" http server (listening on another port than socket.io, of course) is from 127.0.0.1 respectively from the php server over cURL.

Because the both servers are in the same scope, the http server can trigger events on the socket.io server.

My Question: doest that make any sense? Is there a cleaner solution to trigger events on socket.io from PHP?

解决方案

I think that's a reasonable and straightforward way to go; it seems like caution would be advised for dealing with order of execution, but that's probably just my uncertainty with node showing.

这篇关于通过PHP和cURL访问NodeJS / Socket.io的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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