Commit 59134a6e authored by Dominik Charousset's avatar Dominik Charousset

some cleanup

example uses 'EXIT' messages rather than user-defined quit messages and
no longer checks wheter the sender is a proxy, because this might lead
newcomers to believe that such a check is safe (it isn't, because remote
actors can fake the sender information, so that an actor receives a
message "from itself" for example)
parent 91b54cc3
...@@ -60,11 +60,6 @@ class client : public event_based_actor { ...@@ -60,11 +60,6 @@ class client : public event_based_actor {
} }
}, },
on(atom("join"), arg_match) >> [=](const group_ptr& what) { on(atom("join"), arg_match) >> [=](const group_ptr& what) {
if (self->last_sender()->is_proxy()) {
// accept join commands from local actors only
reply("nice try");
}
else {
for (auto g : joined_groups()) { for (auto g : joined_groups()) {
cout << "*** leave " << to_string(g) << endl; cout << "*** leave " << to_string(g) << endl;
send(g, m_name + " has left the chatroom"); send(g, m_name + " has left the chatroom");
...@@ -73,14 +68,6 @@ class client : public event_based_actor { ...@@ -73,14 +68,6 @@ class client : public event_based_actor {
cout << "*** join " << to_string(what) << endl; cout << "*** join " << to_string(what) << endl;
join(what); join(what);
send(what, m_name + " has entered the chatroom"); send(what, m_name + " has entered the chatroom");
}
},
on(atom("quit")) >> [=] {
if (self->last_sender()->is_proxy()) {
// ignore quit messages from remote actors
reply("nice try");
}
else quit();
}, },
on<string>() >> [=](const string& txt) { on<string>() >> [=](const string& txt) {
// don't print own messages // don't print own messages
...@@ -175,7 +162,8 @@ int main(int argc, char** argv) { ...@@ -175,7 +162,8 @@ int main(int argc, char** argv) {
} }
} }
); );
send(client_actor, atom("quit")); // force actor to quit
send(client_actor, atom("EXIT"), exit_reason::user_defined);
await_all_others_done(); await_all_others_done();
shutdown(); shutdown();
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment