简体   繁体   中英

Node.js - Multiple User Handling in With Twitter Streaming

All, i am trying to write a node.js app, which a multiple user can authenticate my app & start streaming with their user account.

What i have done is till now is used a Node Twitter API & started the streaming for one user. (i think streaming means making the http connection open for long time. ?) How to invoke streaming for another user now & make that connection open for both the users?

exports.configure = function(username, done) {
    db.getItemObject(username, function(obj) {
        userData = obj;
        api = new twitter({
            consumer_key : obj.api_token,
            consumer_secret : obj.api_secret,
            access_token_key : obj.access_token,
            access_token_secret : obj.access_secret
        });
        done(true);
    });
};

exports.setTwitAlert = function(res) {
    api.stream('user',{track: ''},function(stream) {
        stream.on('data', function(data) {
            logger.info('Tweet Received !!');
            jsonParser(data);
            res.send('Twitter Streaming Started !!!');
        });
    });
};

I am not asking this question for twitter only. I need a generic answer which is useful other API's. i used twitter for describing my question.

You can take a look at Socket.io .
Good post here: Node, Socket & Twitter API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM