This is a snipped using the old any_type syntax:
on<int, any_type>() >> [](int v1) { }, // 1 on<int, any_type*>() >> [](int v1) { } // 2The semantic of the first line - matching exactly one element of any type - is no longer supported. The second line just needs to replace any_type* with anything to work:
// equal to 2 on<int, anything>() >> [](int v1) { }This will match any message with an integer as first element.
Just one suggestion. I know it might be tedious for you, but I think lots of people would like to take a look at the doxygen-generated doc online, without git-cloning and compiling it. It might be a good idea if you compiled it and uploaded somewhere for everyone to see it.
ReplyDeleteKeep up with the good work!
Hi,
ReplyDeleteyou're absolutely right.
The doxygen documentation is currently under construction and lacks a lot of details. But I'm working on it and I'll upload it as soon as it reaches a presentable state.
When I write
ReplyDeleteon() >> [](int v1) { }
Is there any way for me to use that "anything"? Just as an example, what can be done if I want to use this class to resend everything that came after the integer to another actor? Something similar to:
on() >> [](int v1, "anything my_var") {
send(other_actor, my_var);
}
Sorry but for some reasons the brackets disappeared... It was
ReplyDeleteon< int, anything > () >> [](int v1, "anything my_var")
You could use "last_received()" to access other elements of the received message. A short example:
ReplyDeleteon<int,anything>() >> [](int v1)
{
auto msg = last_received();
if (msg.size() == 2)
{
if (msg.utype_info_at(1) == typeid(float))
{
auto v2 = msg.get_as<float>(1);
// ...
}
else if (msg.utype_info_at(2) == typeid(double))
{
auto v2 = msg.get_as<double>(1);
// ...
}
}
// ...
}
Should be "(msg.utype_info_at(1) == typeid(double))" of course.
ReplyDelete