#include <hmbdc/app/Base.hpp>
using namespace hmbdc::app;
using namespace std;
struct Hello
};
struct WinterComing
WinterComing(int y)
: years(y)
{}
int years;
};
static_assert(sizeof(WinterComing) == 4, "good idea to check message size remain consistsent");
struct Kingslanding
:
Client<Kingslanding, Hello, WinterComing> {
void messageDispatchingStartedCb(uint16_t) override {
cout << "anyone saying hello? - waiting..." << endl;
}
void invokedCb(uint16_t) override {
cout << "I am going to work for a second..." << endl;
sleep(1);
}
void handleMessageCb(Hello const&) {
cout << "someone just said hello" << endl;
}
void handleMessageCb(WinterComing w) const {
cout << w.years << " years winter is coming - exiting" << endl;
throw(0);
}
};
int main() {
Kingslanding kingslanding;
MyContext ctx;
ctx.
start(kingslanding, 0x01);
sleep(3);
ctx.send(Hello());
sleep(2);
ctx.sendInPlace<WinterComing>(500);
ctx.join();
}