Skip to content

Instantly share code, notes, and snippets.

@catlike
Created November 28, 2010 00:52
Show Gist options
  • Save catlike/718450 to your computer and use it in GitHub Desktop.
Save catlike/718450 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra'
require 'lib/sms'
require 'thread'
queue = Queue.new
consumer = Thread.new do
while (true) do
message = queue.pop
outgoing = SMS.new
outgoing.send message['from'], message['to'], "#{message['message']} at #{Time.now}"
sleep(10)
end
end
post '/sms' do
content_type :json
puts "From:" + params['from']
puts "To:" + params['to']
puts "Message:" + params['message']
queue << params
puts "Queue Length:" + queue.length.to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment