]> git.tdb.fi Git - libs/net.git/blob - source/net/receiver.cpp
Add a dynamic receiver class for more flexible packet handling
[libs/net.git] / source / net / receiver.cpp
1 #include "receiver.h"
2
3 namespace Msp {
4 namespace Net {
5
6 void DynamicDispatcher::receive(unsigned packet_id, const Variant &packet)
7 {
8         auto i = lower_bound_member(targets, packet_id, &Target::packet_id);
9         if(i==targets.end() || i->packet_id!=packet_id)
10                 throw key_error(packet_id);
11
12         i->func(*i->receiver, packet);
13 }
14
15 } // namespace Net
16 } // namespace Msp