summaryrefslogtreecommitdiff
path: root/python/qpid/connection.py
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2007-09-12 00:37:17 +0000
committerAndrew Stitcher <astitcher@apache.org>2007-09-12 00:37:17 +0000
commite69abcd0ae75a32c6a618c9b86a8a550fb4a8db7 (patch)
treea759c750ee6abe74c98f6a2bb1c341e35551e09a /python/qpid/connection.py
parentbdba810bed79ed16ba0e73ff852c7cd41aa39c8b (diff)
downloadqpid-python-e69abcd0ae75a32c6a618c9b86a8a550fb4a8db7.tar.gz
* python/qpid/codec.py
Comment typo * cpp/src/qpid/broker/RecoveryManagerImpl.cpp Cruft removal * python/qpid/codec.py * python/qpid/connection.py * cpp/src/qpid/framing/AMQFrame.h * cpp/src/qpid/framing/AMQFrame.cpp Initial implementation of 0-10 framing - This uses the new 12 byte frame header, but doesn't support splitting segments/framesets over multiple frames yet. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@574735 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/connection.py')
-rw-r--r--python/qpid/connection.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/python/qpid/connection.py b/python/qpid/connection.py
index 39bcde17df..11a0d3ec6a 100644
--- a/python/qpid/connection.py
+++ b/python/qpid/connection.py
@@ -92,23 +92,44 @@ class Connection:
def write(self, frame):
c = self.codec
+ c.encode_octet(0x0f) # TODO: currently fixed at ver=0, B=E=b=e=1
c.encode_octet(self.spec.constants.byname[frame.type].id)
- c.encode_short(frame.channel)
body = StringIO()
enc = codec.Codec(body, self.spec)
frame.encode(enc)
enc.flush()
- c.encode_longstr(body.getvalue())
+ frame_size = len(body.getvalue()) + 12 # TODO: Magic number (frame header size)
+ c.encode_short(frame_size)
+ c.encode_octet(0) # Reserved
+ c.encode_octet(frame.subchannel & 0x0f)
+ c.encode_short(frame.channel)
+ c.encode_long(0) # Reserved
+ c.write(body.getvalue())
c.encode_octet(self.FRAME_END)
def read(self):
c = self.codec
+ flags = c.decode_octet() # TODO: currently ignoring flags
+ framing_version = (flags & 0xc0) >> 6
+ if framing_version != 0:
+ raise "frame error: unknown framing version"
type = self.spec.constants.byid[c.decode_octet()].name
+ frame_size = c.decode_short()
+ if frame_size < 12: # TODO: Magic number (frame header size)
+ raise "frame error: frame size too small"
+ reserved1 = c.decode_octet()
+ field = c.decode_octet()
+ subchannel = field & 0x0f
channel = c.decode_short()
- body = c.decode_longstr()
+ reserved2 = c.decode_long() # TODO: reserved maybe need to ensure 0
+ if (flags & 0x30) != 0 or reserved1 != 0 or (field & 0xf0) != 0:
+ raise "frame error: reserved bits not all zero"
+ body_size = frame_size - 12 # TODO: Magic number (frame header size)
+ body = c.read(body_size)
dec = codec.Codec(StringIO(body), self.spec)
frame = Frame.DECODERS[type].decode(self.spec, dec, len(body))
frame.channel = channel
+ frame.subchannel = subchannel
end = c.decode_octet()
if end != self.FRAME_END:
garbage = ""
@@ -145,6 +166,7 @@ class Frame:
def init(self, args, kwargs):
self.channel = kwargs.pop("channel", 0)
+ self.subchannel = kwargs.pop("subchannel", 0)
def encode(self, enc): abstract