Skip to content
/ RT Public

RT.js: unified client-side real-time communication for JavaScript using XHR polling / BOSH / WebSockets / WebRTC

Notifications You must be signed in to change notification settings

foo123/RT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RT

RT

Unified Node/XPCOM/JS client-side real-time communication with underlying implementations for:

see also:

  • ModelView a simple, fast, powerful and flexible MVVM framework for JavaScript
  • Contemplate a fast and versatile isomorphic template engine for PHP, JavaScript, Python
  • HtmlWidget html widgets, made as simple as possible, both client and server, both desktop and mobile, can be used as (template) plugins and/or standalone for PHP, JavaScript, Python (can be used as plugins for Contemplate)
  • Paginator simple and flexible pagination controls generator for PHP, JavaScript, Python
  • ColorPicker a fully-featured and versatile color picker widget
  • Pikadaytime a refreshing JavaScript Datetimepicker that is ightweight, with no dependencies
  • Timer count down/count up JavaScript widget
  • InfoPopup a simple JavaScript class to show info popups easily for various items and events (Desktop and Mobile)
  • Popr2 a small and simple popup menu library
  • area-select.js a simple JavaScript class to select rectangular regions in DOM elements (image, canvas, video, etc..)
  • area-sortable.js simple and light-weight JavaScript class for handling smooth drag-and-drop sortable items of an area (Desktop and Mobile)
  • css-color simple class for manipulating color values and color formats for css, svg, canvas/image
  • jquery-plugins a collection of custom jQuery plugins
  • jquery-ui-widgets a collection of custom, simple, useful jQueryUI Widgets
  • touchTouch a variation of touchTouch jQuery Optimized Mobile Gallery in pure vanilla JavaScript
  • Imagik fully-featured, fully-customisable and extendable Responsive CSS3 Slideshow
  • Carousel3 HTML5 Photo Carousel using Three.js
  • Rubik3 intuitive 3D Rubik Cube with Three.js
  • MOD3 JavaScript port of AS3DMod ActionScript 3D Modifier Library
  • RT unified client-side real-time communication for JavaScript using XHR polling / BOSH / WebSockets / WebRTC
  • AjaxListener.js: Listen to any AJAX event on page with JavaScript, even by other scripts
  • asynchronous.js simple manager for asynchronous, linear, parallel, sequential and interleaved tasks for JavaScript
  • classy.js Object-Oriented mini-framework for JavaScript

Note1 RT is not only a simple framework around real-time layer implementations, it is also a small protocol additional to an implementation, which enables optimum performance, e.g by multiplexing multiple requests transparently (where applicable).

Note2 some BOSH implementations (especialy javascript implementations) are actually XMPP-BOSH implementations (meaning they implement XMPP over BOSH, i.e using BOSH technique and protocol for XMPP). This is just the BOSH, without the XMPP part (which of course can be implemented using the BOSH method of RT or other method e.g websocket, but still it is an autonomous technique in itself)

  • RT is also a XPCOM JavaScript Component (Firefox) (e.g to be used in firefox browser addons/plugins)

Example API

RT Simple Chat

// from real-time chat example

//e.g in node
/*
var RT = require('./RT.js');
require('./RT.Poll.js');
require('./RT.BOSH.js');
require('./RT.WebSocket.js');
*/
// in browser
/*
<script type="text/javascript" src="./RT.js"></script>
<script type="text/javascript" src="./RT.Poll.js"></script>
<script type="text/javascript" src="./RT.BOSH.js"></script>
<script type="text/javascript" src="./RT.WebSocket.js"></script>
*/

var rt_impl = 'ws' /* 'ws'=WebSocket, 'bosh'=BOSH, 'poll'=POll */;

var rt_chat = RT({
        use: rt_impl,
        endpoint: 'ws' === rt_impl ? 'ws:https://127.0.0.1:1111' : ('bosh' === rt_impl ? './relay.php?bosh=1' : './relay.php?poll=1')
    })
    .on('receive', function( evt ){
        if ( !evt.data ) return;
        var m = RT.Util.Json.decode( evt.data );
        output.innerHTML += '<div class="entry'+(m.user===user?' own':'')+'">\
        <span class="user">' + userify( m.user ) + '</span>\
        <span class="message">' + textify( m.message ) + '</span>\
        </div>';
    })
    /*.one('open', function( ){
        alert('OPENED');
    })*/
    .on('close', function( ){
        alert('CLOSED!');
    })
    .on('error', function( evt ){
        alert('ERROR: '+evt.data);
    })
    .init( )
;

function send( event )
{
    if ( RT.Client.OPENED !== rt_chat.status ) return;
    if ( event && (!key_is(event, 13) || event.shiftKey) ) return;
    var msg = RT.Util.String.trim( input.value||'' );
    input.value = '';
    if ( !msg.length ) return;
    rt_chat.send(RT.Util.Json.encode({
        'user': user,
        'message': msg
    }));
}

Etymology of "real" compare to names/symbols of the sun (e.g Ra, Surya, Sol, Helios) compare to rajah, pharaoh, regal, royal, rex, tyrannus (e.g "Oedipus Tyrannus", i.e "Oedipus Rex")

Etymology of "hour" (as in "time", "ώρα") compare to Horus, Helios compare to "ωραίο", oraío, (original: "timely","in time", metaphor for "beatiful")

Really beatiful, isnt it? :))

About

RT.js: unified client-side real-time communication for JavaScript using XHR polling / BOSH / WebSockets / WebRTC

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published