       logger.info "Options based to new Pub/Sub WebSocket:\n
           #{JSON.stringify(@options, null, 2)}"
 
+    @handlers = {}
     @sock = null
     @pingerRef = null
     @recordCount = 0


  # Unsubscribe from a channel.
  unsubscribeAll: ->
    new P (resolve, reject) =>
      if @sock?
        seq = @sequence

                    response.message, null, record.code,
                    record.details, record
                  ))
              else if record.action == 'msg'
                {id, action, chan, msg} = message

                @handlers[chan]?(chan, msg, id)

                setImmediate =>
                  @emit 'message',
                    channel: chan
                    message: msg
                    id: id
              else
                message = 'Valid, but un-handled response type.'
                logger.error "#{message}"
                @emit 'error', new PubSubError("#{message}: #{rec}")

          # WebSocket connection failure
          @sock.once 'connectFailed', (error) =>
            @emit 'connectFailed', error
            logger.error "Failed to connect to Pub/Sub WebSocket"
