-
-
Save tanepiper/f5072d6086635c6003b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var domready = require('domready'); | |
var sockjs = require('sockjs'); | |
var dnode = require('dnode'); | |
var _ = require('underscore'); | |
domready(function () { | |
window.Tweetifies = _.extend({}, { | |
stream: sockjs('/dnode'), | |
dnode: dnode({ | |
foo: function(data) { | |
console.log(data); | |
} | |
}) | |
}); | |
Tweetifies.dnode.on('local', function(local) { | |
_.extend(Tweetifies, { | |
local: local | |
}); | |
}); | |
Tweetifies.dnode.on('remote', function (remote) { | |
_.extend(Tweetifies, { | |
remote: remote | |
}); | |
}); | |
Tweetifies.dnode.pipe(Tweetifies.stream).pipe(Tweetifies.dnode); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* External Dependencies | |
*/ | |
var _ = require('underscore'); | |
/** | |
* This module exports a route for the home page of the application after login | |
*/ | |
module.exports = function(instance) { | |
/** | |
* The function returned to the express rotue | |
*/ | |
return function(req, res, next) { | |
if (!req.session.oauth) { | |
return res.redirect('/'); | |
} | |
var session = _.clone(req.session); | |
require('./../../sockjs_server')(instance, session); | |
res.render('app', { session: req.session }); | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sockjs = require('sockjs'); | |
module.exports = function(instance, session) { | |
var server = sockjs.createServer(); | |
server.on('connection', function(stream) { | |
var d = require('./dnode_server')(instance, session); | |
d.pipe(stream).pipe(d); | |
}); | |
server.installHandlers(instance.express, { prefix : '/dnode' }); | |
instance.sockjs = server; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(instance, session) { | |
console.log(session); | |
var dnode = require('dnode'); | |
var twitter = require('ntwitter'); | |
//var dnodeSession = require('dnode-session')({store: instance.sessions}); | |
//var twitter = require('./../apps/twitter/')(instance, req); | |
var d = dnode(); | |
//d.on('local', dnodeSession); | |
//d.on('local', twitter); | |
d.on('local', function(local) { | |
console.log('local', local); | |
local.foo = function(c) { | |
console.log(c); | |
}; | |
}); | |
d.on('remote', function(remote) { | |
var twit = new twitter(session.oauth); | |
console.log(twit); | |
twit.verifyCredentials(function(err, profile) { | |
twit.stream('user', function(stream) { | |
stream.on('data', function(data) { | |
console.log(data); | |
remote.foo(data); | |
}); | |
}); | |
}); | |
}); | |
d.on('error', function(e) { | |
console.log('error', e); | |
}); | |
setInterval(function() { | |
console.log('touching session'); | |
session.touch(); | |
console.log(session); | |
}, 5000); | |
return d; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment