       handle.callback null, handle
       handle.callback = undefined
     handle.emit "submit"
+    @emit "submit", handle
 
   _completed: (handle, data) ->
     handle.emit "complete", data
+    @emit "complete", handle, data
     @_removeHandle handle
 
   _failed: (handle, data) ->

      handle.callback data, handle
      handle.callback = undefined
    handle.emit "error", data unless handle.listeners("error").length is 0
    @_removeHandle handle

  _addHandle: (handle) ->

    @id = uuid()

# A client submits tasks to a broker.
module.exports = class Client extends EventEmitter
  constructor: (@options) ->
    @handles = {}
    @_connect()
