Skip to content

ThreadWatch on Sinatra

siddick edited this page Sep 27, 2010 · 1 revision

Another method of handling the live data using the ThreadWatch module.

require 'rubygems'
require 'sinatra'
require 'json'
require 'livedata'

get '/live_data/:user_id' do
        wait_time = params[:wait_time] || 15
        obj = LiveData::ThreadWatch.read( params[:user_id] )
        obj.to_json
end

get '/live_data/:user_id/put' do
        obj = LiveData::ThreadWatch.write( params[:user_id], params.dup )
        "OK"
end

Clone this wiki locally