12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/bunny/framing.rb', line 12
def self.decode(string)
= string[HEADER_SLICE]
type, channel, size = self.()
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
if payload.bytesize != size
raise BadLengthError.new(size, payload.bytesize)
end
raise NoFinalOctetError.new if frame_end != AMQ::Protocol::Frame::FINAL_OCTET
self.new(type, payload, channel)
end
|