Más contenido relacionado
La actualidad más candente (20)
Similar a Alpha Streaming Realtime (20)
Alpha Streaming Realtime
- 3. Architecture
Chrome Extension Client Wave Robot
CouchDB Pusher
Rack
NodeJS
express
Frontend
- 4. Chrome -> Rack javascript
function loadResults() {
$.ajax({
type: "GET",
url: query_url,
dataType: "xml",
success: function(wolfram) {
$.ajax({
type: "POST",
url: "http://alpharack.heroku.com",
data:"url=url_here&type=chrome&image_url=image_url_here”,
success: function(m) {
parseXml(wolfram);
}
});
}
});
});
- 5. Wave -> Rack python
form_fields = {
'type': 'wave',
'image_url': pod.getAttribute('src'),
'url': url
}
form_data = urllib.urlencode(form_fields)
result = urlfetch.fetch(
url="http://alpharack.heroku.com",
payload=form_data,
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-form-urlencoded'}
)
- 6. Rack -> Pusher ruby
Pusher['stream'].trigger('new-query',
{
:type => params[:type],
:image_url => params[:image_url],
:url => params[:url]
}
)
Pusher -> Node javascript
flash
fallback
WebSocket.__swfLocation = "/public/js/WebSocketMain.swf";
var socket = new Pusher('appid', 'stream');
socket.bind('new-query', function(query) {
//logic
};
- 7. Rack -> CouchDB ruby
db = CouchRest.database("http://mycouchdb.com:5984/queries")
db.save_doc(
{
:type => params[:type],
:image_url => params[:image_url],
:url => params[:url], :created_at => Time.now
}
) if params[:url] != nil
CouchDB -> Node javascript
$.getJSON("http://url.com/to/couchdb/view", function(data) {
$.each(data.rows, function(i,item) {
if (item.value.type == "chrome") {
//display logic for a chrome query
};
if (item.value.type == "wave") {
//display logic for a wave query
};
});
});
- 10. Try it out!
Chrome Extension http://bit.ly/aOZxY1
Wave Robot Address wave-alpha@appspot.com
Frontend Site http://server.markfayngersh.com:8080