【发布时间】:2012-04-22 20:44:17
【问题描述】:
我正在编写一个 REST API,提供对资源的 CRUD 操作。
我希望用户能够注册某些资源更改并通过服务器推送获取更新。对于服务器推送,我将提供对反向 ajax、隐藏 iframe 和 websockets 的支持。为了尽可能保持 REST,我创建了一个 Streaming 资源来处理注册和与客户端的连接:
流媒体资源:
URI uri : A GET against this URI refreshes the client representation of the resources accessible to this user.
bool WebSocket : Indicate if websocket is available on this server
bool ReverseXHR : Indicate if ReverseXHR is available on this server
bool HiddenIframe : Indicate if HiddenIframe is available on this server
Registration[] Registrations : The set of registration tasks.
OpenChannel : 打开从网络服务器到客户端的流媒体通道。 GET参数类型=(websocket|xhr|hiddeniframe)
CloseChannel : 关闭从网络服务器到客户端的流媒体通道。 GET参数类型=(websocket|xhr|hiddeniframe)
openchannel?type=websocket 的调用将打开 websocket 并开始传输注册值的数据。
我已经阅读了很多文章,但我仍然有点困惑。这样做后我还能调用我的 API REST 吗?如果不是(或是),为什么?
感谢您的帮助!
【问题讨论】:
-
你是怎么做到的?我不会担心模式的纯度——服务器推送越来越重要。我想知道你是如何实现这个的..
标签: rest websocket comet reverse-ajax