From cac3c2109afe3656c871dd197e1e98ef536ce350 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 3 Apr 2012 18:10:16 +0200 Subject: [PATCH] Cleaned up (Un)RegisterMethod methods. --- jsonrpc/connectionmanager.cpp | 16 ++++------------ jsonrpc/connectionmanager.h | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/jsonrpc/connectionmanager.cpp b/jsonrpc/connectionmanager.cpp index 681d5fb0b..c4a8566f3 100644 --- a/jsonrpc/connectionmanager.cpp +++ b/jsonrpc/connectionmanager.cpp @@ -66,25 +66,17 @@ int ConnectionManager::NewMessageHandler(NewMessageEventArgs::Ptr nmea) void ConnectionManager::RegisterMethod(string method, function callback) { - map >::iterator i; - i = m_Methods.find(method); - - if (i == m_Methods.end()) { - m_Methods[method] = event(); - i = m_Methods.find(method); - } - - i->second += callback; + m_Methods[method] += callback; } -void ConnectionManager::UnregisterMethod(string method, function function) +void ConnectionManager::UnregisterMethod(string method, function callback) { - // TODO: implement + m_Methods[method] -= callback; } void ConnectionManager::SendMessage(JsonRpcMessage::Ptr message) { - /* TODO: filter messages based on event subscriptions */ + /* TODO: filter messages based on event subscriptions; also loopback message to our own handlers */ for (list::iterator i = m_Clients.begin(); i != m_Clients.end(); i++) { JsonRpcClient::Ptr client = *i; diff --git a/jsonrpc/connectionmanager.h b/jsonrpc/connectionmanager.h index 72a4563b2..62b049be1 100644 --- a/jsonrpc/connectionmanager.h +++ b/jsonrpc/connectionmanager.h @@ -24,8 +24,8 @@ public: void RegisterClient(JsonRpcClient::Ptr client); void UnregisterClient(JsonRpcClient::Ptr client); - void RegisterMethod(string method, function function); - void UnregisterMethod(string method, function function); + void RegisterMethod(string method, function callback); + void UnregisterMethod(string method, function callback); void SendMessage(JsonRpcMessage::Ptr message); };