codelego / phpfox-realm
phpfox框架的实时消息传输层接口。
dev-master
2016-11-29 10:44 UTC
This package is not auto-updated.
Last update: 2024-09-28 20:14:38 UTC
README
原型
1. $message = new Message(); 2. $recipinents = (select friend of sender).result; 3. $pusher->push($message, $recipinents);
- 创建新的消息以推送。
$message = new Message([ id: int, identity of message, name: string, type of message, sender_id: int, who send the message, data: array, link: [], where to redirected, title: string, title of mesage, summary: string, some line describe about message, creation: datetime, when was this posted, expiration: int , when it will expires, ]);
- 与套接字层协同工作
- 每个用户可能连接到多个服务器(可扩展)。
- 每条消息必须在套接字服务器上中继。
- 维护
- 我们只支持NodeJS套接字服务器。
- 为没有NodeJs设置环境的客户端或测试提供云NodJS服务器。
解决方案01
- 发布消息
- 使用正常的Ajax post到web服务器。
- 向客户端响应消息已发布。
- 服务器将在套接字服务器上中继以传递消息。
- 通过WebSocket获取消息
- 保持客户端连接。
- 套接字服务器将请求作为代理和连接容器处理。
- 套接字服务器以异步方式操作,无需等待和阻塞IO。它获取消息,将其保存在消息容器中,然后发送到消息交付。
解决方案02
- 发布消息
- 使用正常的Ajax post到web服务器。
- 向客户端响应消息已发布。
- 服务器将消息发布到消息队列服务(本地、SQS等)。
- 通过WebSocket获取消息
- 保持客户端连接,以子发布原型连接到消息队列。
- 长轮询请求
- 发布消息
- 使用正常的Ajax post到web服务器。
- 向客户端响应消息已发布。
- 不执行任何操作
- 获取消息
- 客户端向服务器发送Ajax请求。
- 服务器正在查找消息。
- 如果没有新消息,它将空闲,然后在[x]次后重试。
- 使用自定义推送服务[作为WebSocket工作]。
- [pusher] (https://pusher.com/)
- ...