Example #1
0
var JsonRpcWrapper = function(){
	this.client = rpc.getClient(80, 'ideone.com');
	this.path = '/api/1/service.json';
	this.call = function(method, params, callback){
		this.client.call(method, params, callback, null, this.path);
	}
}
Example #2
0
you.events.on('clientReady', function(clientId) {
	var client = you.getClient(clientId);
	console.log('Calling fatCat');
	client.you.fatCat('hello from server', function(res) {
		console.log(res);
	});
});
Example #3
0
    function setCachingEngine(id) {
        try {

            var cache_engine = require('./cache-engines/' + id);

            if (!cache_engine.set || !cache_engine.get) {
                console.warn("Default cache engine used. No get and set methods in cache engine", id);
                return setCachingEngine(DEFAULT_CACHE);
            }

            cache.set = cache_engine.set;
            cache.get = cache_engine.get;

            if (cache_engine.getClient) {
                cache[id] = cache_engine.getClient();
            }

            console.log("Using cache engine:", id);

        } catch (ex) {
            if (id == DEFAULT_CACHE) {
                throw ex;
            } else {
                console.warn("Default cache engine used. Check CONFIG.CACHE_ENGINE. ", ex.stack);
                setCachingEngine(DEFAULT_CACHE);
            }
        }
    }
Example #4
0
		oauth : function(service_name, config, callback) {
			
			var oa = tracker.getClient(service_name);
			
			app.get('/bind/' + service_name, function(req, res){
				oa.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, results){
					if (error) {
						console.log(error);
						res.send("There was an error connecting to " + service_name);
					}
					else {
						req.session.oauth = {};
						req.session.oauth.token = oauth_token;
						req.session.oauth.token_secret = oauth_token_secret;
						res.redirect(config.authorize + '?oauth_token='+oauth_token)
				}
				});
			});

			app.get('/bind/' + service_name + '/callback', function(req, res, next){
				
				if (req.session.oauth) {
					req.session.oauth.verifier = req.query.oauth_verifier;
					var oauth = req.session.oauth;

					oa.getOAuthAccessToken(oauth.token,oauth.token_secret,oauth.verifier, 
					function(error, oauth_access_token, oauth_access_token_secret, results){
						if (error){
							callback(error, null);
						} else {
							req.session.oauth.access_token = oauth_access_token;
							req.session.oauth,access_token_secret = oauth_access_token_secret;
							callback(null, arguments);
							res.redirect('/');
						}
					});
				} else {
					next(new Error("you're not supposed to be here."))
				}
			});
		},
Example #5
0
File: index.js Project: jangot/cms
 _getDbClient : function() {
     return db.getClient();
 }