Commit c156f11a authored by Julien Muchembled's avatar Julien Muchembled

protocol: small cleanup in packet registration

Same as commit a00ab78b.

It was reverted mistakenly when switching to msgpack.
parent e434c253
......@@ -312,6 +312,8 @@ class Packet(object):
class PacketRegistryFactory(dict):
_next_code = 0
def __call__(self, name, base, d):
for k, v in d.items():
if isinstance(v, type) and issubclass(v, Packet):
......@@ -323,10 +325,9 @@ class PacketRegistryFactory(dict):
def register(self, doc, ignore_when_closed=None, request=False, error=False,
_base=(Packet,), **kw):
""" Register a packet in the packet registry """
code = len(self)
if doc is None:
self[code] = None
return # None registered only to skip a code number (for compatibility)
code = self._next_code
assert code < RESPONSE_MASK
self._next_code = code + 1
if error and not request:
assert not code
code = RESPONSE_MASK
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment