 class Job extends Stream
   constructor: (@gearman, @name, @payload) ->
     @timeoutTimer = null
-    @gearman.sendCommand "SUBMIT_JOB", @name, false, @payload, @receiveHandle.bind(@)
+    @gearman.sendCommand "SUBMIT_JOB", @name, false, @payload, @receiveHandle.bind @
 
   setTimeout: (timeout, timeoutCallback) ->
     @timeoutValue = timeout

    @aborted = true

  receiveHandle: (handle) ->
    if handle
      @handle = handle
      @gearman.currentJobs[handle] = @
    else
      @emit "error", new Error("Invalid response from server")

module.exports = Job

  updateTimeout: () ->
    return if not @timeoutValue
    clearTimeout @timeoutTimer
    @timeoutTimer = setTimeout (@onTimeout.bind @), @timeoutValue

  onTimeout: () ->
    delete @gearman.currentJobs[@handle] if @handle
