GithubHelp home page GithubHelp logo

centrifuge's Introduction

CENTRIFUGE

Simple platform for real-time message broadcasting in web applications.

The main goal of Centrifuge is the same as in Pusher or Pubnub services. The main difference is that Centrifuge is open-source and requires installation (it is worth noting that installation is rather simple).

It is built on top of Tornado - extremely fast and mature Python's async web server.

Centrifuge uses ZeroMQ steroid sockets for internal communication and publish/subscribe operations.

For presence and history data Centrifuge utilizes Redis - advanced and super fast in memory key-value store.

To connect to Centrifuge from browser pure Websockets or SockJS library can be used.

Centrifuge comes with administrative web interface to manage project/namespace structure and monitor important messages.

Persistent data (projects, namespaces) by default stored in SQLite database. But when running Centrifuge instance processes on different machines you should use MongoDB or PostgreSQL backends instead of SQLite for structure management.

Please, read the documentation, watch screencast and look at examples for more information.

Main features

  • Asynchronous backend on top of Tornado
  • SockJS and pure Websockets endpoints
  • Simple javascript client
  • Presence and history data for channels
  • Web interface for managing your projects
  • Flexible channel settings through namespaces

Basic usage from browser

var centrifuge = new Centrifuge({
    url: 'http://localhost:8000/connection',  // Centrifuge SockJS connection endpoint
    token: 'TOKEN', // token based on project's secret key, project ID and user ID
    project: 'PROJECT_ID', // project ID from Centrifuge admin interface
    user: 'USER_ID', // your application user ID (can be empty for anonymous access)
});

centrifuge.on('connect', function() {

    console.log('connected');

    var subscription = centrifuge.subscribe('django', function(message) {
        // message from channel received
        console.log(message);
    });

    subscription.on('ready', function(){
        subscription.presence(function(message) {
            // information about who connected to channel at moment received
        });
        subscription.history(function(message) {
            // information about last messages sent into channel received
        });
        subscription.on('join', function(message) {
            // someone connected to channel
        });
        subscription.on('leave', function(message) {
            // someone disconnected from channel
        });
    });

});

centrifuge.on('disconnect', function(){
    console.log('disconnected');
});

centrifuge.connect();

For more information about javascript client API see documentation chapter

Architecture diagram

centrifuge

Admin web interface

admin_web_interface

To run tests type the following from tests directory (centrifuge must be in PYTHONPATH):

# IMPORTANT! Tests clear Redis database on every running. Be aware of this.
python -m unittest discover -p 'test_*.py'

Contributing

Pull requests are welcome! But, please, follow next principles:

  • keep things as simple as possible
  • pep8
  • python 2.6, 2.7 and 3.3 compatible

P.S. If BSD license of Centrifuge does not allow you to use it, tell me and I'll consider to change license.

Bitdeli Badge

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.