Skip to content

Instantly share code, notes, and snippets.

@tmzt
Created March 2, 2011 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmzt/850776 to your computer and use it in GitHub Desktop.
Save tmzt/850776 to your computer and use it in GitHub Desktop.
models.js
module.exports = function(path, callback) {
/* ... */
models = require('models');
//models.UnreadClippings.count = models.UnreadClippings.count.bind(models.UnreadClippings);
models.UnreadClippings.incr = models.UnreadClippings.incr.bind(models.UnreadClippings);
/* express routes */
callback(app, models); };
var cluster = require('./cluster');
var http = require('http');
var connect = require('connect');
var dnode = require('dnode');
var development = require('./development/app.js');
development(__dirname + '/development', function(server, models) {
cluster(server).use(cluster.debug()).listen(8033);
dnode(function(c){
this.UnreadClippings = models.UnreadClippings;
}).listen({protocol: 'socket.io', server: server, transports: ['xhr-polling']});
});
function UnreadClippings() {
console.log('this: ', this);
this._count = 0;
this.queue = [];
this.updateclient = function(count) { console.log('queueing update: ', count); this.queue.push({'type': 'updt', 'count':this._count});};
this.incr = function() {
this._count++;
console.log('incr() this.updateclient: ', this.updateclient);
if (this.updateclient) {
this.updateclient(this._count);
};
};
this.init = function(updateclient) {
console.log('init() this: ', this);
this.updateclient = updateclient;
};
};
module.exports.UnreadClippings = new UnreadClippings();
console.log('_count: ', module.exports.UnreadClippings._count);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment