Parent

Methods

Class/Module Index [+]

Quicksearch

AMQ::Client::Framing::String::Frame

Public Class Methods

decode(string) click to toggle source
# File lib/amq/client/framing/string/frame.rb, line 38
def self.decode(string)
  header              = string[HEADER_SLICE]
  type, channel, size = self.decode_header(header)
  data                = string[DATA_SLICE]
  payload             = data[PAYLOAD_SLICE]
  frame_end           = data[-1, 1]

  frame_end.force_encoding(AMQ::Protocol::Frame::FINAL_OCTET.encoding) if ENCODINGS_SUPPORTED

  # 1) the size is miscalculated
  if payload.bytesize != size
    raise BadLengthError.new(size, payload.bytesize)
  end

  # 2) the size is OK, but the string doesn't end with FINAL_OCTET
  raise NoFinalOctetError.new if frame_end != AMQ::Protocol::Frame::FINAL_OCTET

  self.new(type, payload, channel)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.