Sha256: ef591da9cfb1801befe0fa60c4517b5486120c5fb33583c0c622b34c2cd2cda0

Contents?: true

Size: 585 Bytes

Versions: 2

Compression:

Stored size: 585 Bytes

Contents

module EMJack
  module Handler
    class Reserved
      RESPONSE = /^RESERVED\s+(\d+)\s+(\d+)\r\n/

      def self.handles?(response)
        if response =~ RESPONSE
          [true, $2.to_i]
        else
          false
        end
      end

      def self.handle(deferrable, response, body, conn)
        return false unless response =~ RESPONSE
        id = $1.to_i
        bytes = $2.to_i

        job = EMJack::Job.new(conn, id, body)
        deferrable.succeed(job)

        true
      end

      EMJack::Connection.register_handler(EMJack::Handler::Reserved)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-jack-0.0.8 lib/em-jack/handlers/reserved.rb
em-jack-0.0.7 lib/em-jack/handlers/reserved.rb