开发者

Realtime Streaming per User via some Comet Server

开发者 https://www.devze.com 2023-04-09 19:22 出处:网络
I need to design a Streaming API where each connected user might have different data per category. Lets say two users are interested in sport(category) rss feeds from the streaming api but each user

I need to design a Streaming API where each connected user might have different data per category.

Lets say two users are interested in sport(category) rss feeds from the streaming api but each user has its own filtering mechanism on the server 开发者_JAVA技巧which results in different push data sets...

By using juggernaut , you can stream data through categories(channels) but i couldn't find a way to filter some part of the data per category on the server side depending on user filter settings.


Channels are usually used for filtering data i.e. one for /SPORT/FOOTBALL/PREMIERLEAGUE/MANU, another /SPORT/FOOTBALL/CHAMPIONSHIP/WESTHAM and /SPORT/GOLF/USMASTERS.

I only know of one realtime Comet server which offers additional filtering though subscriptions to the channels and that is Caplin System's Liberator. For example (pseudocode):

var subscriber = new Subscriber();
var filter = "headline~transfer"; // where '~' means contains
subscriber.subscribe("/SPORT/FOOTBALL/PREMIERLEAGUE/MANU", filter, function(update) {
   // handle update
});

The above code would subscribe to the channel but only send updates whenever and update came in where the headline field contained the text transfer.

Another solution that appears to offer this querying functionality is pubsub.io. From their site:

// connect from node
var pubsub = require('pubsub.io').connect('hub.pubsub.io/238258');
// or the browser
var pubsub = pubsubio.connect('hub.pubsub.io/238258');

pubsub.subscribe({
    hello:{$any:['world','mundo','verden']}
}, function(doc) {
    console.log(doc);
});

pubsub.publish({hello:'world'});

This sort of channel querying may well be something we start to see more of.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号