Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

comet.io

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comet.io

light-weight comet server & client

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

comet.io

Lightweight comet server & client for Node.js

Server

var app = require('http').createServer(handler);
var file = new(require('node-static').Server)(__dirname + '/web', {});
var comet = require('../lib/comet.io.js').createServer();

app.listen(8000);
function handler(request, response) {
  request.on('end', function() {
    if (!comet.serve(request, response)) {
      file.serve(request, response, function(err, res) {
        if (err) { console.log(err); }
      });
    } 
  });
}

comet.on('connection', function (socket) {
  // do something when a client has connected
  socket.emit('test.message', { something:'any json object here' });

  socket.on('test.response', function(data) {
    // do something when it receives a message from client
  });
});

Client

  socket = comet.connect();
  socket.on('connect', function() {
    // do something when it's connected for the first time
  }).on('test.message', function (data) {
    // do something, such as sending an message to the server
    socket.emit('test.response', { something:'any json object' });
  });

Keywords

FAQs

Package last updated on 01 Dec 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc