PHP应用程序+在Socket.IO基于WebSocket的通知 [英] PHP application + WebSocket based notifications over Socket.IO

查看:1104
本文介绍了PHP应用程序+在Socket.IO基于WebSocket的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用laravel PHP编写的Web应用程序。

I have a web application written in PHP using laravel.

现在,我要补充一点,从服务器推信息的实时通知系统 - >客户端,可以检索信息从推送到客户端 - >服务器

Now, I have to add realtime notification system that pushes messages from server -> client, and can retrieve messages pushed from client -> server.

由于Socket.IO是向后兼容的,并缓慢下降,我想使用它的WebSocket的/ AJAX投票的部分。

Since Socket.IO is backwards compatible and degrades gracefully, I want to use it for the WebSocket / AJAX polling part.

问题在于Socket.IO默认作品与Node.js的后端。

The problem is that Socket.IO by default works with Node.JS backend.

我有服务器的root访问权限,没有运行在两个(Apache和节点)没有问题,并行或添加额外的东西。

I have root access to the server, there is no problem running both (Apache and Node) in parallel or adding anything extra.

问题是,我怎么发送邮件从PHP到节点+ Sockets.IO?

然后,如何从Sockets.IO +节点传输邮件到PHP?

我已经离开了节点+套接字到浏览器的一部分了,因为那是pretty直线前进。

I have left the Node + Sockets to Browser part out, because that's pretty straight forward.

我见过的例子使用<一个href=\"http://stackoverflow.com/questions/11550103/push-notifications-using-socket-io-and-php\">Ex$p$pss.js +卷曲和/或POST请求的,但是,是不是有这样做的一个较低的水平的方式?

I have seen examples utilising Express.js + CURL and/or POST requests, but, isn't there a lower level way of doing it?

我知道 DNode + PHP ,但我无法想象如何组装一切 - 阿帕奇,PHP,节点,Socket.IO,DNode所以会一起无缝地协同工作。

I am aware of DNode + PHP, but I cannot imagine how to assemble everything - Apache, PHP, Node, Socket.IO, DNode so it would work together seamlessly.

另外,我已经变成了一个laravel库这个 PHP服务器的WebSockets执行。与此库的问题,虽然,是它利用干净的WebSockets为它的客户端。而且,我无法找到一个方法来与 Socket.IO客户一起破解它。

Also, I have transformed into a laravel library this PHP WebSockets server implementation. The problem with this library, though, is that it utilizes clean WebSockets for it's client side. And, I couldn't find a way to hack it together with Socket.IO client.

推荐答案

本教程使用PHP和Socket.IO 回答你的问题的主要部分。

This tutorial on using PHP and Socket.IO answers the main part of your question.

socket.io是不是你唯一的选择。看一看在实时网络技术指南。通过它的外观最佳的基于PHP的解决方案,现在是棘轮。这需要作为一个单独的进程中运行,所以你仍然要具备跨进程通信问题。

socket.io isn't your only options. Have a look at the realtime web tech guide. By the looks of it the best PHP-based solution right now is Ratchet. This needs to run as a separate process so you're still going to have the cross-process communication problem.

常见的跨进程通信的问题是使用消息队列。那么问题就来了,当你想在Apache的PHP应用程序的运行被告知从实时网络技术的事件英寸你可能会不得不做,通过网络电话,即使是在实时网络技术工艺Apache服务器的呼叫。

The common cross process communication problem is to use messages queues. The problem then comes in when you want your PHP app running on Apache to be informed of events from the realtime web technology. You're probably going to have to do that via a web call, even if it's a call from the realtime web tech process to the apache server.

另一个选择是卸载实时通信像谁我工作的托管服务。

Another option is to offload the realtime communication to a hosted service like Pusher who I work for.

这最近的问题也是相关的,有一些有用的链接:<一个href=\"http://stackoverflow.com/questions/12203443/web-sockets-is-native-php-support-available/#12204603\">Is可用网络套接字原生支持PHP?

This recent question is also relevant and has some useful links: Is native PHP support for Web Sockets available?

这篇关于PHP应用程序+在Socket.IO基于WebSocket的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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