real time web (orbited) at bcne3
TRANSCRIPT
Real Time Web
Or having a socket in your browserOrbited, Django, MorbidQ
“ideas2gather”
Alex Kavanagh@ajkavanagh
STOMPhttp://stomp.codehaus.org/
The Stomp project is the Streaming Text Orientated Messaging Protocol site (or the Protocol Briefly Known as
TTMP and Represented by the symbol :ttmp).
ideas2gather
(A real-time pledging system for Newcastle Council Health and Well-being Partnership event)
{% extends "base.html" %}{% block title%}idea2gather - '{{ event.name }}'{% endblock %}{% block script %}<link rel="stylesheet" href="/static/css/site-wide.css" type="text/css" /><meta name="channel" content="/topic/{{ event.key }}" /><meta name="javascript-debug" content="true" /><meta name="event-key" content="{{ event.key}}"/><script>document.domain=document.domain</script><script src="http://{{ orbited_host }}/static/Orbited.js"></script><script>Orbited.settings.port = 9000;TCPSocket = Orbited.TCPSocket;Orbited.settings.streaming = false;</script><script src="http://{{ orbited_host }}/static/protocols/stomp/stomp.js"></script>
function setup_stomp(context, params) { // get our connection to the STOMP server var stomp = new STOMPClient(); stomp.onconnectedframe = function() {
stomp.ready = true;stomp.subscribe(context.CHANNEL);
setTimeout(params.connect_function, 4000); }; // set up the receive function. stomp.onmessageframe = function(frame) {
params.receive_function( frame ); };
...
...
var logger = Orbited.getLogger("example"); var reconnectTimer = null; stomp.onopen = function() { if(reconnectTimer) window.clearTimeout(reconnectTimer); }; stomp.onclose = function(c) { logger.debug('Lost Connection, Code: ' + c); reconnectTimer = window.setTimeout( function () { params.reconnect(context); }, 1000); // TODO: autoincrease with cap }; stomp.connect(document.domain, 61613); //, 'guest', 'guest'); return stomp;}