Comet client and server libraries for Node.js
JavaScript
Latest commit e68c2d2 May 10, 2010 Brainfucker example
Failed to load latest commit information.
client example May 10, 2010
server example May 9, 2010
README.md example May 9, 2010
index.html example May 9, 2010
server.js example May 9, 2010

README.md

Node.js comet module (Beta!)

Demo: http://chat.nodejs.ru

Use: node ./server.js To start chat example server

Client side:

  • constructor: new cometClent(server [string], anonymous [boolean]);
    • server: path to application like: http://example.com/:8080 or /server if you have routes
    • anonymous: set true if you don't want to remember users
  • onRecive(callback [function])
  • connect(data [object])
  • disconnect(data [object])
  • send(data [object])

Usage: var client=new cometClient('ajax-request-path');

client.onRecive(function(data) {
    // Recive an message
});

client.connect({text: 'Create data (unnessusary)'});

client.send({text: 'Sent data'});

Server side

  • constructor: new comet.server(timeout [integer]);
  • onRecive(user [object], callback [function])
  • onConnect(user [object], callback [function])
  • onDisconnect(user [object], callback [function])

Usage: var comet = require('./lib/comet');

var server = new comet.server(30000);

server.onRecive(function(user, data) { // New message from an user
    // Recive an message
    user.send({text: 'Message to current user'});
});

server.send('*',{text: 'Message to all users'});