IBus.cs 1012 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. namespace Wayne.Lib.MessageBus
  3. {
  4. /// <summary>
  5. /// Wayne internal message bus. Topic-based publish and subscription.
  6. /// Topic is a string with "/". When subscribing it is possible to enter "*" on a position,
  7. /// so for example topic filter "A/*/C" will match topic "A/B/C", "A/C/C" etc.
  8. /// </summary>
  9. public interface IBus
  10. {
  11. /// <summary>
  12. /// Publish a message on the bus.
  13. /// </summary>
  14. /// <param name="topic"></param>
  15. /// <param name="message"></param>
  16. void Publish(string topic, object message);
  17. /// <summary>
  18. /// Subscribe to the bus.
  19. /// </summary>
  20. /// <typeparam name="T"></typeparam>
  21. /// <param name="topicFilter"></param>
  22. /// <param name="action"></param>
  23. /// <returns>A disposable object that is should be disposed when subscription should be ended.</returns>
  24. IDisposable Subscribe<T>(string topicFilter, Action<string, T> action);
  25. }
  26. }