X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnet%2Fprotocol.cpp;h=ce200a2c0ea49afed1f320b0914c252a094669bd;hb=1565dec0f4a86e4bda7095dd7415234f7c7a84e9;hp=81e9d142a56f93615152a9bfb7b5040ffe05b8ab;hpb=92e8064d9f43ca3e28ce9832cfe475034ab98704;p=libs%2Fnet.git diff --git a/source/net/protocol.cpp b/source/net/protocol.cpp index 81e9d14..ce200a2 100644 --- a/source/net/protocol.cpp +++ b/source/net/protocol.cpp @@ -14,8 +14,8 @@ Protocol::Protocol(unsigned npi): header_def(0), next_packet_id(npi) { - PacketDefBuilder >(*this, header_def, NullSerializer()) - (&PacketHeader::type)(&PacketHeader::length); + PacketDefBuilder>(*this, header_def, Serializer()) + .fields(&PacketHeader::type, &PacketHeader::length); } Protocol::~Protocol() @@ -56,11 +56,11 @@ const Protocol::PacketDefBase &Protocol::get_packet_by_id(unsigned id) const size_t Protocol::dispatch(ReceiverBase &rcv, const char *buf, size_t size) const { PacketHeader header; - buf = header_def.deserialize(header, buf, buf+size); + const char *ptr = header_def.deserialize(header, buf, buf+size); if(header.length>size) throw bad_packet("truncated"); const PacketDefBase &pdef = get_packet_by_id(header.type); - const char *ptr = pdef.dispatch(rcv, buf, buf+header.length); + ptr = pdef.dispatch(rcv, ptr, ptr+header.length); return ptr-buf; } @@ -166,11 +166,6 @@ Protocol::PacketDefBase::PacketDefBase(unsigned i): { } -Protocol::PacketHeader::PacketHeader(): - type(0), - length(0) -{ } - Protocol::PacketHeader::PacketHeader(uint16_t t, uint16_t l): type(t), length(l)