Find out the sender when a message is received

23 views
Skip to first unread message

Dulaj Viduranga

unread,
Aug 29, 2019, 3:36:14 PM8/29/19
to actor-framework
Hi,
I have an application where a message receiver needs to find out who the sender is and do the processing accordingly. Is it possible to check this inside a behavior lambda?

Thanks.

Dominik Charousset

unread,
Aug 29, 2019, 4:34:33 PM8/29/19
to actor-f...@googlegroups.com
> I have an application where a message receiver needs to find out who the sender is and do the processing accordingly. Is it possible to check this inside a behavior lambda?

Yes: self->current_sender().

You can have a look at the Dining Philosophers example to see it in use: https://github.com/actor-framework/actor-framework/blob/master/examples/dynamic_behavior/dining_philosophers.cpp.

Dominik

Dulaj Viduranga

unread,
Aug 30, 2019, 6:29:00 AM8/30/19
to actor-framework
Thank you Dominik. This is helpful. Is there a way to compare the strong_actor_ptr I get from this against a typed_actor type (without having the handle to the specific actor) to check if the message is sent from a specific type of actor?
Reply all
Reply to author
Forward
0 new messages