20 std::map<
void *, std::function<void(T)>> mReceiverCallbacks;
27 for (
auto objectCallbackPair : mReceiverCallbacks)
30 T _receivedMessage{T::Deserialize(payload)};
32 std::function<void(T)> _callback = objectCallbackPair.second;
33 _callback(std::move(_receivedMessage));
43 virtual
void Send(const T &message) = 0;
48 void SetReceiver(
void *
object, std::function<
void(T)> receiver)
50 mReceiverCallbacks[object] = receiver;
Network communication abstraction layer.
Definition: network_layer.h:18
void FireReceiverCallbacks(const std::vector< uint8_t > &payload)
Fire all the set receiver callaback.
Definition: network_layer.h:25
virtual void Send(const T &message)=0
Send a message through the network.
void SetReceiver(void *object, std::function< void(T)> receiver)
Set a receiver callback.
Definition: network_layer.h:48