Пример #1
0
 def _pack_frame(self, frame):
     s = BytesIO()
     c = Codec(s)
     c.encode_octet(self.spec.constants.bypyname[frame.payload.type].id)
     c.encode_short(frame.channel)
     frame.payload.encode(c)
     c.encode_octet(self.FRAME_END)
     data = s.getvalue()
     return data
Пример #2
0
 def _unpackFrame(self, data):
     s = StringIO(data)
     c = Codec(s)
     frameType = spec.pythonize(self.spec.constants.byid[c.decode_octet()].name)
     channel = c.decode_short()
     payload = Frame.DECODERS[frameType].decode(self.spec, c)
     end = c.decode_octet()
     if end != self.FRAME_END:
         raise GarbageException('frame error: expected %r, got %r' % (self.FRAME_END, end))
     frame = Frame(channel, payload)
     return frame
Пример #3
0
 def send_init_string(self):
     s = BytesIO()
     c = Codec(s)
     c.pack("!4s4B", b"AMQP", 1, 1, self.spec.major, self.spec.minor)
     self.transport.write(s.getvalue())
Пример #4
0
 def sendInitString(self):
     initString = "!4s4B"
     s = StringIO()
     c = Codec(s)
     c.pack(initString, "AMQP", 1, 1, self.spec.major, self.spec.minor)
     self.transport.write(s.getvalue())