X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnet%2Fprotocol.h;h=0721ec5b5403adebb4013e54a07358700beebecc;hb=c2e9e03b191a6ffe44a83be32aadf2a325491c02;hp=f040a69ef1293665b3f38c79387706c04bf75e05;hpb=ede42d5bb352841e2e425972e12b8ef31ddf2123;p=libs%2Fnet.git diff --git a/source/net/protocol.h b/source/net/protocol.h index f040a69..0721ec5 100644 --- a/source/net/protocol.h +++ b/source/net/protocol.h @@ -7,26 +7,27 @@ #include #include #include +#include "mspnet_api.h" #include "receiver.h" namespace Msp { namespace Net { -class bad_packet: public std::runtime_error +class MSPNET_API bad_packet: public std::runtime_error { public: bad_packet(const std::string &w): std::runtime_error(w) { } }; -class buffer_error: public std::runtime_error +class MSPNET_API buffer_error: public std::runtime_error { public: buffer_error(const std::string &w): std::runtime_error(w) { } }; -class Protocol +class MSPNET_API Protocol { private: template @@ -225,10 +226,10 @@ protected: public: template - std::size_t serialize(const P &, char *, std::size_t) const; + std::size_t serialize(const P &, char *, std::size_t, unsigned = 0) const; std::size_t get_packet_size(const char *, std::size_t) const; - std::size_t dispatch(ReceiverBase &, const char *, std::size_t) const; + std::size_t dispatch(ReceiverBase &, const char *, std::size_t, unsigned = 0) const; std::uint64_t get_hash() const; }; @@ -264,14 +265,14 @@ const Protocol::PacketTypeDef

&Protocol::get_packet_by_class() const } template -std::size_t Protocol::serialize(const P &pkt, char *buf, std::size_t size) const +std::size_t Protocol::serialize(const P &pkt, char *buf, std::size_t size, unsigned base_id) const { const PacketTypeDef

&pdef = get_packet_by_class

(); if(!pdef.get_id()) throw std::invalid_argument("no packet id"); char *ptr = pdef.serialize(pkt, buf+4, buf+size); size = ptr-buf; - header_def.serialize(PacketHeader(pdef.get_id(), size), buf, buf+4); + header_def.serialize(PacketHeader(base_id+pdef.get_id(), size), buf, buf+4); return size; }