       @processJob job, callback
 
   processJob: (job, callback) =>
-    {uuid,token,message} = job
+    {auth,message} = job
+    {uuid,token} = auth
 
     authDevice uuid, token, (error, device) =>
       return callback error if error?
 
-      @sendMessage device, message, message.topic, callback
+      @sendMessage device, message, callback
 
-  sendMessage: (device, message, topic, callback) =>
-    @_sendMessage device, message, topic
+  sendMessage: (device, message, callback) =>
+    @_sendMessage device, message
     callback()
 
 worker = new Worker()

async = require 'async'
redis = require './lib/redis'
authDevice = require './lib/authDevice'
sendMessageCreator = require './lib/sendMessage'
createMessageIOEmitter = require './lib/createMessageIOEmitter'

class Worker
  constructor: ->
    @_sendMessage = sendMessageCreator createMessageIOEmitter()

  run: =>
    async.whilst @true, @popMessage, (error) =>

  true: => true

  popMessage: (callback) =>
    redis.client.brpop 'meshblu-messages', 1, (err, result) =>
      return callback err if err?
      return callback() unless result?
      [queueName, jobStr] = result
