Sha256: 7183b3f53b64afbb4c1debdfaf8c21fc308a02b09e14fdb7d4dac22fa005f9ff

Contents?: true

Size: 899 Bytes

Versions: 42

Compression:

Stored size: 899 Bytes

Contents

# encoding: utf-8

require "amq/client/exceptions"

module AMQ
  module Client
    module Framing
      module IO

        class Frame < AMQ::Protocol::Frame
          def self.decode(io)
            header = io.read(7)
            type, channel, size = self.decode_header(header)
            data = io.read(size + 1)
            payload, frame_end = data[0..-2], data[-1, 1]
            # TODO: this will hang if the size is bigger than expected or it'll leave there some chars -> make it more error-proof:
            # BTW: socket#eof?
            raise NoFinalOctetError.new if frame_end != AMQ::Protocol::Frame::FINAL_OCTET
            self.new(type, payload, channel)
          end # self.from

        end # Frame
      end # IO
    end # Framing
  end # Client
end # AMQ

class AMQ::Protocol::Frame
  def final?
    true ####### HACK for testing, implement & move to amq-protocol!
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
amq-client-0.7.0.alpha1 lib/amq/client/framing/io/frame.rb
amq-client-0.5.0 lib/amq/client/framing/io/frame.rb