I've figured out that Meteor (as in http://meteor.com) is using SockJS under the hood.
我发现《流星》(http://meteor.com)在引擎盖下使用的是SockJS。
I have some server-side code that periodically check what song is playing in iTunes and I want to publish the track info to the client side.
我有一些服务器端代码,定期检查iTunes中播放的歌曲,我想将曲目信息发布到客户端。
I've looked at Meteors docs, and Meteor.publish/Meteor.subscribe seem to specifically deal with Meteor.Collections. I just want to pass through arbitrary data, like strings or JSON.
我看过流星纪录片和流星。订阅似乎专门处理流星收集。我只想传递任意数据,比如字符串或JSON。
Is there anyway I can do simple pub/sub in Meteor like Socket.IO or Faye?
我可以在流星堆里做简单的酒吧/潜水吗?IO还是法耶?
1 个解决方案
#1
3
You can publish arbitrary data. It doesn't have to come from a Meteor.Collection.
可以发布任意数据。它不需要来自流星收集。
See http://docs.meteor.com/#meteor_publish for a starting point. You'll want to write a publish function on the server which calls Meteor.setInterval
to set up a periodic check, and then uses this.set
, this.unset
, and this.flush
to push individual attributes to each client.
请参见http://docs.meteor.com/#meteor_publish获得起点。您将希望在服务器上编写一个名为燎的发布函数。setInterval设置一个周期检查,然后使用它。集,这。复原,这。刷新将单个属性推送到每个客户端。
#1
3
You can publish arbitrary data. It doesn't have to come from a Meteor.Collection.
可以发布任意数据。它不需要来自流星收集。
See http://docs.meteor.com/#meteor_publish for a starting point. You'll want to write a publish function on the server which calls Meteor.setInterval
to set up a periodic check, and then uses this.set
, this.unset
, and this.flush
to push individual attributes to each client.
请参见http://docs.meteor.com/#meteor_publish获得起点。您将希望在服务器上编写一个名为燎的发布函数。setInterval设置一个周期检查,然后使用它。集,这。复原,这。刷新将单个属性推送到每个客户端。