redundant unsubscribing should be fine

This commit is contained in:
Adam R. Grey 2021-09-03 04:45:47 -04:00
parent 5dde912564
commit 21c7e4d050

View File

@ -138,15 +138,23 @@ namespace franz
_TelefranzConsumers<T>.wrappings[theAction] = wrapped;
topicSubscribers[topic]++;
}
public void removeHandler<T>(Action<T> theAction) where T : silver_messages.message
public bool removeHandler<T>(Action<T> theAction) where T : silver_messages.message
{
topicConsumers[typeof(T).ToString()].MessageReceived -= _TelefranzConsumers<T>.wrappings[theAction];
if (_TelefranzConsumers<T>.wrappings.ContainsKey(theAction))
{
_TelefranzConsumers<T>.wrappings.Remove(theAction);
topicSubscribers[typeof(T).ToString()]--;
if (topicSubscribers[typeof(T).ToString()] == 0)
{
topicConsumers[typeof(T).ToString()].StopConsume();
}
return true;
}
else
{
return false;
}
}
public void ProduceMessage<T>(T message) where T : silver_messages.message