All Projects → rousan → comet

rousan / comet

Licence: MIT license
A http long polling comet implementation for nodejs and browser

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to comet

cettia-java-server
A full-featured real-time web application framework for Java
Stars: ✭ 40 (+100%)
Mutual labels:  comet, long-polling
use-axios-hooks
axios hooks for common network calls scenarios
Stars: ✭ 27 (+35%)
Mutual labels:  polling
qlicker
Open Source Clicker
Stars: ✭ 23 (+15%)
Mutual labels:  polling
comet-server
CppComet - easy to use and fast in work.
Stars: ✭ 57 (+185%)
Mutual labels:  comet
laravel-chat
chat application build with laravel and gopusher gateway.
Stars: ✭ 32 (+60%)
Mutual labels:  comet
aiosfstream
Salesforce Streaming API client for asyncio
Stars: ✭ 46 (+130%)
Mutual labels:  comet
Telegrambots
Java library to create bots using Telegram Bots API
Stars: ✭ 2,728 (+13540%)
Mutual labels:  polling
rpc ts
Remote Procedure Calls in TypeScript made simple 🤞
Stars: ✭ 71 (+255%)
Mutual labels:  long-polling
CometJS
Desktop Development built up on, Javascript, HTML, CSS, Chromium and Firefox.
Stars: ✭ 12 (-40%)
Mutual labels:  comet
EncoderTool
The EncoderTool is a library to manage and read out rotary encoders connected either directly or via multiplexers to ARM based boards. Encoder push buttons are supported. Callback functions can be attached to encoder changes and button presses to allow for event driven applications
Stars: ✭ 29 (+45%)
Mutual labels:  polling
polling2
Powerful polling utility in Python
Stars: ✭ 49 (+145%)
Mutual labels:  polling
toiler
Toiler is a AWS SQS long-polling thread-based message processor.
Stars: ✭ 15 (-25%)
Mutual labels:  polling
lightning-hydra-template
PyTorch Lightning + Hydra. A very user-friendly template for rapid and reproducible ML experimentation with best practices. ⚡🔥⚡
Stars: ✭ 1,905 (+9425%)
Mutual labels:  comet
Bitpoll
A web application for scheduling meetings and general polling.
Stars: ✭ 182 (+810%)
Mutual labels:  polling
mcp3008.js
A node.js module for querying an mcp3008 analog/digital converter.
Stars: ✭ 24 (+20%)
Mutual labels:  polling
Restbed
Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications.
Stars: ✭ 1,551 (+7655%)
Mutual labels:  comet
java-vk-bots-long-poll-api
A Java library to create VK bots using Bots Long Poll API
Stars: ✭ 30 (+50%)
Mutual labels:  long-polling
PAW pipeline
A Comet-based, best practices proteomics pipeline.
Stars: ✭ 22 (+10%)
Mutual labels:  comet
ember-poller
A poller service based on ember-concurrency
Stars: ✭ 15 (-25%)
Mutual labels:  polling
spring-file-poller
A simple spring boot application that demonstrates file polling using the Spring Integration DSL
Stars: ✭ 25 (+25%)
Mutual labels:  polling

NPM version Required Node version NPM total downloads Contributors License

What is http long polling?

Http long polling is used in real-time application where server pushes the data changes to client using simple HTML5 ajax mechanism.

First client makes a request to an HTTP endpoint in the usual way, with the intention of requesting data it has not yet received. If there is no new data available, then the server holds the request open until data becomes available to respond with. After receiving a response (whether new data or timeout), the transaction is complete. The client may create a new request to listen for further data.

comet

The comet is a implementation of http long polling or comet application model which abstracts the internal http requests and provides high-level websocket alike API.

Installation

Using npm:

$ npm install --save comet

Using yarn:

$ yarn add comet

Usage

Here is simple example to push n-th fibonacci numbers to client:

The server:

import http from 'http';
import CometServer from 'comet/server';

const server = http.createServer();
const pollingServer = new CometServer({ server });

pollingServer.on('connection', (conn, data) => {
  let { fibPos } = data;
  console.log(`New connection with fibpos: ${fibPos}`);

  setInterval(() => {
    conn.send({ pos: fibPos, value: fib(fibPos++) });
  }, 1000);
});

server.listen(8888);

const fib = (n) => {
  let num = 0;
  let num2 = 1;
  let fibonacci;

  for (let i = 0; i < n; i++) {
    fibonacci = num + num2;
    num = num2;
    num2 = fibonacci;
  }

  return num;
};

The client:

import CometClient from 'comet/client';

const fibPos = Math.floor(Math.random() * 10);
const longPollingClient = new CometClient('http://localhost:8888/polling', {
  data: { fibPos },
});

longPollingClient.on('message', (m) => {
  console.log(`${m.pos}th: ${m.value}`);
});

longPollingClient.on('open', (conn) => {
  console.log('Connection opened');
  console.log(`Receiving fibonacci numbers from ${fibPos}th position:`);
});

See example for further guide.

Contributing

Your PRs and stars are always welcome.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].