Class: AMQ::Client::Framing::String::Frame
- Inherits:
-
Protocol::Frame
- Object
- Protocol::Frame
- AMQ::Client::Framing::String::Frame
- Defined in:
- lib/amq/client/framing/string/frame.rb
Constant Summary collapse
- ENCODINGS_SUPPORTED =
defined? Encoding
- HEADER_SLICE =
(0..6).freeze
- DATA_SLICE =
(7..-1).freeze
- PAYLOAD_SLICE =
(0..-2).freeze
Class Method Summary collapse
Class Method Details
.decode(string) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/amq/client/framing/string/frame.rb', line 39 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 |