Code Monkey home page Code Monkey logo

centrifuge's Introduction

CENTRIFUGE

Simple real-time messaging in web applications.

Quick start

pip install centrifuge
centrifuge

Go to http://localhost:8000 - this is an administrative interface of Centrifuge node you just started. More about installation and configuration in documentation.

Overview

In a few words: clients (users of your web application/site) connect to Centrifuge from browser, after connecting clients subscribe on channels. Every message which was published into that channel will be delivered to all clients which are currently subscribed on that channel.

To connect to Centrifuge from browser pure Websockets or SockJS library can be used. So it works in both modern and old browsers (IE 7 supported). Centrifuge has javascript client with simple API.

Backend is built on top of Tornado - fast and mature asynchronous web server which can handle thousands of simultaneous connections.

Centrifuge scales using Redis PUB/SUB capabilities. Single full-featured instance of Centrifuge run by default without extra dependency on Redis.

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

Persistent data (projects, namespaces) by default stored in SQLite database. When running Centrifuge instance processes on different machines MongoDB or PostgreSQL backends can be used instead of SQLite. There is an option to hard-code all these settings in JSON file and go without any dependency on database.

There are tons of examples in internet about how to add real-time events on your site. But very few of them provide complete, scalable, full-featured, ready to deploy solution. Centrifuge aims to be such a solution with simplicity in mind.

Main features

  • Asynchronous backend on top of Tornado
  • SockJS and pure Websockets connection endpoints
  • Simple javascript client
  • Presence information, message history, join/leave events for channels
  • Web interface to manage your projects
  • Flexible channel settings via namespaces
  • Language agnostic - you can go with Centrifuge even if your site built in Perl, PHP, Ruby etc.
  • Easily integrates with existing web site.

To get more information:

Various packages and tools related to Centrifuge located in Centrifugal organization here on Github.

scheme

Similar projects / alternatives:

Basic usage from browser

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

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

Admin web interface

admin_web_interface

Tests

IMPORTANT! At moment tests require Redis running and clear database on every running. Be aware of this!

pip install tox
tox

or just

python setup.py test

Contributing

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

  • keep things simple
  • pep8 friendly
  • python 2.6, 2.7, 3.3 and 3.4 compatible

LICENSE

MIT

Bitdeli Badge Requirements Status

centrifuge's People

Contributors

fzambia avatar nigma avatar korneevm avatar bitdeli-chef avatar dobrite avatar pahaz avatar

Watchers

James Cloos avatar Artur Barseghyan avatar  avatar

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.