Created
November 28, 2010 00:52
-
-
Save catlike/718450 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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