Cleaned up (Un)RegisterMethod methods.

This commit is contained in:
Gunnar Beutner 2012-04-03 18:10:16 +02:00
parent bfcb5019d5
commit cac3c2109a
2 changed files with 6 additions and 14 deletions

View File

@ -66,25 +66,17 @@ int ConnectionManager::NewMessageHandler(NewMessageEventArgs::Ptr nmea)
void ConnectionManager::RegisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback)
{
map<string, event<NewMessageEventArgs::Ptr> >::iterator i;
i = m_Methods.find(method);
if (i == m_Methods.end()) {
m_Methods[method] = event<NewMessageEventArgs::Ptr>();
i = m_Methods.find(method);
}
i->second += callback;
m_Methods[method] += callback;
}
void ConnectionManager::UnregisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> function)
void ConnectionManager::UnregisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> 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<JsonRpcClient::Ptr>::iterator i = m_Clients.begin(); i != m_Clients.end(); i++)
{
JsonRpcClient::Ptr client = *i;

View File

@ -24,8 +24,8 @@ public:
void RegisterClient(JsonRpcClient::Ptr client);
void UnregisterClient(JsonRpcClient::Ptr client);
void RegisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> function);
void UnregisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> function);
void RegisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback);
void UnregisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback);
void SendMessage(JsonRpcMessage::Ptr message);
};