Skip to content

Instantly share code, notes, and snippets.

@MarkySparky
Last active August 29, 2015 14:18
Show Gist options
  • Save MarkySparky/6c282a2be9c962535858 to your computer and use it in GitHub Desktop.
Save MarkySparky/6c282a2be9c962535858 to your computer and use it in GitHub Desktop.
socketIO handler
// ContentHandler that emits a socketio message on content creation
//
// The ContentSource will call the method of this object as it fetched the content.
module.exports = function() {
var fs = require('fs');
var df = require('dateformat');
var del = require('del');
var yaml = require('js-yaml');
var root = 'app';
var config = yaml.safeLoad(fs.readFileSync('config.yaml', 'utf8'));
return {
// called when the content source is starting
start: function(callback) {
console.log('Starting Socket io' ['cyan'].bold);
callback();
},
// called for each content item provided by the content source
handleContentItem: function(item, callback) {
console.log(item.url);
console.log('Handling content - publushing on socket io');
callback();
},
// called when the content source will provide no more items
end: function() {
console.log('Ending');
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment