Home

Awesome

RT

RT

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

see also:

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)

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://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? :))