[Backgroundrb-devel] Internet cafe application

Guillaume Viguier-Just gviguier at cs.umass.edu
Sat Jul 25 17:07:14 EDT 2009


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 =>

class TimerWorker < BackgrounDRb::MetaWorker
  set_worker_name :timer_worker
  def create(args = nil)
    add_periodic_timer(60) { decrement_time }

  def decrement_time
    key = worker_key
    logger.debug('worker key: #{key}')

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

More information about the Backgroundrb-devel mailing list