summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiftob/Commands.cpp')
-rw-r--r--Swiftob/Commands.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/Swiftob/Commands.cpp b/Swiftob/Commands.cpp
index cf24196..18f9fb0 100644
--- a/Swiftob/Commands.cpp
+++ b/Swiftob/Commands.cpp
@@ -41,6 +41,10 @@ void Commands::registerCommand(const std::string& name, RoleList roles, const st
command->onReceived.connect(callback);
}
+void Commands::registerListener(ListenerCallback listener) {
+ listeners_.push_back(listener);
+}
+
bool Commands::hasCommand(const std::string& name) {
return commands_.find(name) != commands_.end();
}
@@ -57,6 +61,12 @@ bool Commands::runCommand(const std::string& name, const std::string& params, Sw
return false;
}
+void Commands::runListeners(Swift::Message::ref message) {
+ foreach (ListenerCallback listener, listeners_) {
+ listener(message);
+ }
+}
+
bool Commands::roleIn(const Users::User::Role userRole, RoleList roleList) {
switch (roleList) {
case Owner : return userRole == Users::User::Owner;
@@ -84,6 +94,7 @@ void Commands::handleRehashCommand(const std::string& /*command*/, const std::st
replyTo(message, "Rehashing now.");
std::cout << "Rehashing at the behest of " << message->getFrom().toString() << std::endl;
resetCommands();
+ listeners_.clear();
if (rehashError_.empty()) {
replyTo(message, "Rehash complete");
} else {