Guillaume Viguier-Just
2009-Jul-25 21:07 UTC
[Backgroundrb-devel] Internet cafe application
Hello, I''m trying to achieve the following: an Internet cafe server application written using RoR which will receive timecodes from clients (for example: abcdefgh). These timecodes will be looked up in a database and, if a match is found in the database, a timer will be started on the server (and should be started in a new thread), which will, amongst other things, decrement the time that is left for this specific timecode every minute. I hope I''m being clear... I''ve looked at backgroundrb and it seems to be the right tool to achieve this but, even after reading the website documentation, I''m still confused on how I could achieve this. I started implementing it in the following way: class ClientsController def connect_timecode # check timecode and if timecode is valid: MiddleMan.new_worker(:worker => :timer_worker, :worker_key => @client.session_id) end end class TimerWorker < BackgrounDRb::MetaWorker set_worker_name :timer_worker def create(args = nil) add_periodic_timer(60) { decrement_time } end def decrement_time key = worker_key logger.debug(''worker key: #{key}'') end end Problem is: - this displays "worker key: nil" all the time, which means that for some reason the worker key is nil and this will not allow me to retrieve the client by its session id and perform some operations on the client - I''m not sure whether the approach I''m using is right Any help on this would be greatly appreciated. Thank you. -- Guillaume Viguier-Just