Comet是一种将实时数据推送到Web浏览器的技术 - 因此页面可以不断更新.有关更多详细信息,请参阅此页面关于Comet.
发布/订阅(或发布/订阅)是不是不同的彗星,它是告诉你要接收(订阅)什么数据彗星服务器并发送数据到其他用户(发布)的方式.许多Comet服务器实现了pub/sub模型.
订阅:我想收到有关Google的新闻:
hub.subscribe("/news/google", function(sTopic, oData) { alert("Received news article about Google: " + oData.Article});
Run Code Online (Sandbox Code Playgroud)
发布:我想提供一些关于Google的新闻:
hub.publish("/news/google", "{'Title':'Google Expanding Access To Wave Soon, First Impressions','Article':'According to Google, included in this group of early testers will be some of the businesses using Google Apps. In anticipation of this wider release, ...'}");
Run Code Online (Sandbox Code Playgroud)
任何订阅主题"/ news/google"的人都会收到我上面发表的文章 - 这就是pub/sub的工作原理.
| 归档时间: |
|
| 查看次数: |
1714 次 |
| 最近记录: |